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 375,231 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 2,193 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

Problem with ajax and mozilla browser

Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

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  
All times are GMT -4. The time now is 4:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC