Child elements of xml in javascript array

Clielimobia

New Member
I have a question about putting a xml child files in an javascript array. I have the following xml file:\[code\] <?xml version="1.0" encoding="UTF-8"?><questionaire> <title>Festival enquete</title> <author>Lars Groot </author> <description>Demografische vragen</description> <question id="0"> <subject>demografie</subject> <note>Deze vraag is eigenlijk bedoeld om mensen op het verkeerde been te zetten</note> <text>Wat is uw leeftijd?</text> <answertype>meerkeuze</answertype> <answers> <q>100</q> <q>200</q> <q>300</q> </answers> </question> <question id="1"> <text>Waar komt u vandaan</text> <answertype>openbox</answertype> </question> <question id="2"> <text>Wat is uw geslacht</text> <answertype>meerkeuze</answertype> <answers> <q>Vrouwtje<q> <q>Mannetje<q> </answers> </question> <question id="3"> <text>Waarom stel ik deze vraag</text> <answertype>meerkeuze</answertype> </question></questionaire>\[/code\]And i want to push the answers which are marked by q in a javascript array. I have used the next code to get the childs:\[code\]function vraag(){ string = "questions.xml"; $.get(string,{},function(xml){ $('question',xml).each(function(){ question = $(this).find("text").text(); id = $(this).attr('id'); subject = $(this).find("subject").text(); answertype = $(this).find("answertype").text(); answer = $(this).children("answers").text();\[/code\]Now i want to put answer in an javascript array. So q 100 is answer[0], q 200 is answer[1] and q 300 is answer[2]My question is how to do that?
 
Back
Top