Parsing XML with jQuery when nodes have multiple elements with same name

psicoganso

New Member
I have some XML I'm trying to parse with jQuery, where the node has several elements with the same name. Sample XML:\[code\]<jobs> <job> <name>Technician</name> <skill>computuer repair</skill> <skill>cell phone repair</skill> </job></jobs>\[/code\]When I try to use ajax to get and parse the XML with the \[code\]find\[/code\] method, it doesn't work. But if i only have one skill listed under the \[code\]<job>\[/code\] node, it WILL work. Is there some way of parsing without re-writing my XML? Here's my jQuery code:\[code\] $.ajax({ type: "GET", url: "data/roles.xml", dataType: "xml", success: parseXml }); function parseXml(data){ $(data).find("job").each(function(){ var jobTitle = $(this).find("name").text(); //using the console to test success for now and //readability on SO, appends results to html console.log(jobTitle); }) }\[/code\]
 
Back
Top