How to parse nested XML file using Javascript? -


<types>    <type id='1' name='sport'>       <subtypes id='1' name='football' />             <subtypes id='2' name='tennis' />    </type>        <type id='2' name='education'>       <subtypes id='1' name='school' />             <subtypes id='2' name='university' />    </type> </types> 

i have previous xml file, , want parse using javascript, how can access subtypes specific type ?

i used

var x=xmlhttp.responsexml.documentelement.getelementsbytagname("type");  

to parse types , how can parse subtypes each type ?

var x=xmlhttp.responsexml.documentelement.getelementsbytagname("type");  (var = 0; < x.length; i++) {   var subtypes = new array();   var y = x[i].getelementsbytagname("subtypes")   (var j = 0; j < y.length; j++){     subtypes.push(y[j])     // or process them here   }    // process subtypes in type  } 

that should there... idk want these subtypes though


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -