How to get the exact node info - XML parsing question
-
Hi My xml looks like this and I have pasted the code below to parse. The issue is : The first two table nodes have just the LocnId info. So when I fetch LocnId and Zip code, the result of parsing is like this LocnId Zip 1 30339 2 20000 8 undefined 9 undefinde Expected output is LocnId Zip 1 null 2 null 8 30339 9 20000 1
2
830339
920000
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.load("data.xml"); var x = xmlDoc.getElementsByTagName('Table'); for (var i = 0; i < x.length; i++) { LocnId = xmlDoc.getElementsByTagName("LocnId")[i].childNodes[0].nodeValue; Zip = xmlDoc.getElementsByTagName("Zip")[i].childNodes[0].nodeValue; } I am trying to figureout other methods to fetch the node values, but havent figured out yet, any links/help is greatly appreciated. Thanks Joe
-
Hi My xml looks like this and I have pasted the code below to parse. The issue is : The first two table nodes have just the LocnId info. So when I fetch LocnId and Zip code, the result of parsing is like this LocnId Zip 1 30339 2 20000 8 undefined 9 undefinde Expected output is LocnId Zip 1 null 2 null 8 30339 9 20000 1
2
830339
920000
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.load("data.xml"); var x = xmlDoc.getElementsByTagName('Table'); for (var i = 0; i < x.length; i++) { LocnId = xmlDoc.getElementsByTagName("LocnId")[i].childNodes[0].nodeValue; Zip = xmlDoc.getElementsByTagName("Zip")[i].childNodes[0].nodeValue; } I am trying to figureout other methods to fetch the node values, but havent figured out yet, any links/help is greatly appreciated. Thanks Joe
You can try XPath[^], which is easy and efficient.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions