Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drilling iinto xml

Status
Not open for further replies.

ice78991

Programmer
Nov 20, 2006
216
Hello

I am trying to drill into the following xml file

<data>

<settings>
<loop>yes</loop>
</settings>

<stats>
<file>
<image>1.bmp</image>
<caption>Kresge</caption>
</file>
<file>
<image>2.bmp</image>
<caption>Ka</caption>
</file>
</stats>

</data>

I want to enumerate the number of <file> nodes

I am using the following

xmlNode = this.firstChild;
numberOfFiles=xmlNode.childNodes[1].childNodes.length;

but it's returning undefined

Where have I gone wrong?



 
The way you're accessing the XML nodes is fine; the problem is elsewhere. May be you're trying to access the variable "numberOfFiles" from outside of the XML object? If you post your code we can tell you.

Kenneth Kawamoto
 
Thanks for your help. Basic error on my part
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top