Hi,
Consider this xml as:-
book.xml
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="web" cover="paperback">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
Now I get a XMLDOM object to be used in JavaScript using Firefox XML Parser using XMLHttpRequest.
Say the XML DOM is stored in variable
<script type="text/javascript">
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.documentElement.childNodes;
for (i=0;i<x.length;i++)
{
document.write(x[i].nodeName);
document.write("<br />");
}
</script>
outputs:-
#text
book
#text
book
#text
book
#text
book
#text
A total of 9 child nodes. Howcome ? I see that <bookstore>
has only 4 child nodes as <book>
.
Please help me in understanding this.
Thanks. Aiwee