I am using the below code to iterate through multiple nodes of XML but it seems not working
var xmlDat = $.parseXML($('#xmlText').val());
// Here I am reading an XML content on paste event of xmlText
var xml = $(xmlDat);
var path = xml.find('ProjectID').text();
xml.find('a,b,c,d').each(function(){
{
// Giving unwanted results
}
but if use like below
xml.find('a').each(function(){
{
// Giving results
}
Please let me know how can i correct the code to make this working in above case also…
It works fine in ie9.
In ie7 however you will need to use
filterinstead offindsince ie shaves of the outer element, so<root><a></a><b></b></root>effectively becomes<a></a><b></b>.All in all
Example here: http://jsfiddle.net/bUvPB/5/
Alternativly, to make the same code work in all browsers, wrap your xml in a dummy element first, and then use
findalways, that way you don’t need browser sniffing and other ugly tools to be cross browser compatible.example: http://jsfiddle.net/bUvPB/25/