Parsing levels of XML in jquery

ahanda

New Member
Here is my XML. I am going to have many Degrees, each Degree will have many schools, and each school will have many Specializations. The Page will gave three dropdowns. I am not asking for all the code to preform all the onclicks nested dropdown updates. (unless someone has some cool recurrence pattern what would work. This problem I am having is when I ask for the degree from the Degrees node and add the text() to the dropdown I get all the text from the degree,school,spec... so what I want is a dropdown with "Degree 1", but I get "Degree 1 School 1 Spec...", I am sure you get the idea, I have tried adding "Degrees.filter, and children" but then I get nothing. I need to get a handle on how to parse the XML with nested nodes once level at a time. Thanks for your time.\[code\]<Degrees> <Degree> Degree 1 <Schools> <School>School 1 <Specializations> <Specialization>Specialization 1</Specialization> <Specialization>Specialization 2</Specialization> </Specializations> </School> <School>School 2 <Specializations> <Specialization>Specialization 3</Specialization> <Specialization>Specialization 4</Specialization> </Specializations> </School> </Schools> </Degree></Degrees>\[/code\]The current JQuary\[code\]var Degrees = $(PID).find('Degrees'); Degrees.find("Degree").filter("Degree").each(function () { var select = $('#degree'); var value = http://stackoverflow.com/questions/10884994/$(this).text(); select.append("<option value='" + value + "'>" + value + "</option>"); });\[/code\]The HTML\[code\]<select id="degree"> <option value="" selected="selected">-- Select Degree --</option></select>\[/code\]
 
Back
Top