On of your problems arises from the fact that nodes includes text nodes as well as elements.
Although learning XPath is a big step it makes extracting information so much easier and for simple documents it resembles a file path.
The path to the <participant>s would be:
so
Code:
function parseXML(theXML)
{
var sXPath = "/event/participant";
var colParticipant = theXML.selectNodes(sXPath);
alert("Participant count: " + colParticipant.length);
for (var i = 0; i < colParticipant.length; i++)
{
var oParticipant = colParticipant[i];
var oFirstname = oParticipant.selectNodes("firstname")[0];
var oLastname = oParticipant.selectNodes("lastname")[0];
alert(oFirstname.childNodes[0].nodeValue + " " + oLastname.childNodes[0].nodeValue);
}
}
Thre are hundreds of tutorials on XPath, try W3Schools for starters.
--
Joe (
Microsoft MVP - XML)