This is better. The arrays are much more efficient, and I cut the code by more than half. I know, I know JSON, I will get there, this is teaching me way more though. I still would like to be able to determine my level of nesting abstractly, and also getting out non- standard attributes. function parseXml(xml) { $(xml).find('sites').each(function(){ var PARENTarr = jQuery.makeArray($(this).find('>element')); var CHILDarr = jQuery.makeArray($(PARENTarr).find('>element')); $.each(PARENTarr, function(i){ var PfromA = $(this); var Pid = $(this).attr("label")+$(this).attr("id"); var Cid = $(CHILDarr[i]).attr("label"); $("div").append("<br/>"+Pid +"<br/>" + Cid +"<br/>"); $(CHILDarr[i]).each(function(){ var CHILDattrs = jQuery.makeArray($(this).find('>element')); $(CHILDattrs).each(function(){ var CHILDid = $(this).attr('label') +": "+ $(this).text(); $("div").append(CHILDid +"<br/>"); }); }); }); }); } });
- [jQuery] A different approach to parsing XML, and a little h... augur
- Re: [jQuery] A different approach to parsing XML, and a... Michael Geary
- [jQuery] Re: A different approach to parsing XML, a... augur
- Re: [jQuery] Re: A different approach to parsin... Michael Geary
- [jQuery] Re: A different approach to parsin... augur
- [jQuery] Re: A different approach to p... augur
- [jQuery] Re: A different approach ... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- Re: [jQuery] Re: A different a... Michael Geary
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur
- Re: [jQuery] Re: A different a... Michael Geary
- Re: [jQuery] Re: A different a... Michael Geary
- [jQuery] Re: A different appro... augur
- [jQuery] Re: A different appro... augur