User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 330,147 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,948 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3222 | Replies: 24 | Solved
Reply
Join Date: Jun 2006
Location: India
Posts: 6,611
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Problem with ajax and mozilla browser

  #21  
Jan 25th, 2008
You have got to realize that when we talk of XML, the whitespaces in your document matter and they get counted as a "#text" node. Assuming that xmlObj has the reference of the root node of the document, something like alert(xmlObj.childNodes[1].firstChild.nodeValue); should do the trick.

Here:
xmlObj -> <code> (Element)
childNodes[0] -> Whitespace (Text Node)
childNodes[1] -> <name> (Element)
firstChild -> sree (Text node)
nodeValue -> sree

Assuming the XML file is:
<?xml version="1.0" standalone="yes"?>
<code>
    <name>sree</name>
</code>
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Sep 2005
Posts: 557
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 33
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Posting Pro

Help Re: Problem with ajax and mozilla browser

  #22  
Jan 25th, 2008
Originally Posted by ~s.o.s~ View Post
You have got to realize that when we talk of XML, the whitespaces in your document matter and they get counted as a "#text" node. Assuming that xmlObj has the reference of the root node of the document, something like alert(xmlObj.childNodes[1].firstChild.nodeValue); should do the trick.

Here:


Assuming the XML file is:
<?xml version="1.0" standalone="yes"?>
<code>
    <name>sree</name>
</code>


I'd suggest making sure you don't have any whitespace in your XML. That way, you don't need to have to cater for text nodes where you don't want them.

It may also be better to traverse the XML nodes, instead of selecting 'blindly', unless you are 100% sure the XML structure will not change.

eg: to get first non-text child

function getFirstChildTag(Node) {
var len = Node.childNodes.length;
for (var i = 0; i < len; i++)
   if (Node.childNodes[i].nodeName != '#text') return Node.childNodes[i];
}

master.value = getFirstChildTag(xmlObj).firstChild.nodeValue;

or use DOM methods such as getElementsByTagName() so that you're sure you're getting only what you want.

master.value=xmlObj.getElementsByTagName('name')[0].firstChild.nodeValue

If selecting 'blindly', test for the existence of each parent node first, then fallback if it doesn't exist.

eg:

if (xmlObj && xmlObj.childNodes ... etc
else ... etc
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,611
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 21
Solved Threads: 297
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Problem with ajax and mozilla browser

  #23  
Jan 25th, 2008
Of course, running a while loop till I get what I want or picking up elements based on their tag name is how I normally do things. I just wanted to let the OP know where he had made a mistake.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Sep 2005
Posts: 557
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 33
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Posting Pro

Help Re: Problem with ajax and mozilla browser

  #24  
Jan 25th, 2008
Originally Posted by ~s.o.s~ View Post
Of course, running a while loop till I get what I want or picking up elements based on their tag name is how I normally do things. I just wanted to let the OP know where he had made a mistake.


Was aiming that at OP and the DOM universe in general..
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Mar 2006
Posts: 36
Reputation: sree22_happy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
sree22_happy's Avatar
sree22_happy sree22_happy is offline Offline
Light Poster

Solution Re: Problem with ajax and mozilla browser

  #25  
Jan 30th, 2008
Originally Posted by ~s.o.s~ View Post
You have got to realize that when we talk of XML, the whitespaces in your document matter and they get counted as a "#text" node. Assuming that xmlObj has the reference of the root node of the document, something like alert(xmlObj.childNodes[1].firstChild.nodeValue); should do the trick.

Here:


Assuming the XML file is:
<?xml version="1.0" standalone="yes"?>
<code>
    <name>sree</name>
</code>



thanks a lot it worked fine.........
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 1:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC