javascript xml parser undefined check

cerbero

New Member
Im parsing an xml file with javascript like this :\[code\]x = xmlDoc.getElementsByTagName("Name")[0].childNodes[0];\[/code\]Everything works as expected, except that some times when i dont have an entry "Name" in the xml it shows this error :\[code\]xmlDoc.getElementsByTagName("Name")[0] is undefined\[/code\]which crash my website.Is there any way to check if xmlDoc.getElementsByTagName("Name")[0] has a value and then continue to parse this value to a variable?
 
Back
Top