Build DropDown List With JavaScript via XML file -
i have xml structure:
<sport id="1" name="soccer"> <category id="257" name="countryname"> <tournament id="11275" uniqueid="722" name="tournament name" uniquetournamentname="tournament name"> <team id="5447831" name="team name" superid="38529" /> </tournament> </category> </sport>
and saved soccer.xml, want build dropdown list show
soccer -countryname --tournament ---team
thanks helps
since don't know if have multiple categories, tournament , teams inside 1 sports, assume don't. simple code access in vanilla js
xmldoc=loadxmldoc("soccer.xml"); // document name var sports=xmldoc.getelementsbytagname("sports"); (i=0;i<sports.length;i++) { // iterate throught each sports document.write(sports[i].nodename+"<br>"+ "-"+sports[i].childnodes[0].nodename+"<br>"+ "--"+sports[i].childnodes[0].childnodes[0].nodename+"<br>"+ "---"+sports[i].childnodes[0].childnodes[0].childnodes[0].nodename+"<br>"); }
Comments
Post a Comment