View Single Post
  #1 (permalink)  
Old August 28th, 2005, 09:19 PM
rvanandel rvanandel is offline
Authorized User
Join Date: Dec 2004
Location: Chesterfield, MO, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parsing XML with Javascript

I am working on a web application using the xmlhttprequest object. The returned xml looks something like this

   <name>Event Name</name>
   <start>August 10, 2005</start>
   <end>August 11, 2005</end>

I wrote a function that parses the returned XML but can't figure out how to return the elements in between the participant tags. Here's what I have so far

function parseXML(theXML) {
   var participants = theXML.getElementsByTagName("participant");

When I do a count of childnodes for each participants object, I would expect to see 2 childnodes, but instead I get much more.

For example, using the code snippet alert(participants[0].childNodes.length), I would expect to see 2 (firstname and lastname). Is there another way to do this, or is there any websites that you can direct me to that will give me some in depth information on parsing XML documents.

Robbert van Andel