Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

xml javascript read

in javascript, with xml string "<people><firstname>John</firstname><lastname>John</lastname></people>"

how can loop them like?

foreach ()
alert(xml<firstname> = 'john')
next

I do not want to call one by one. I just want to loop through all the nodes.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use : https://api.jquery.com/jQuery.parseXML/

var strXML =  "<people><firstname>John</firstname><lastname>John</lastname></people>";
var xml = jQuery.parseXML(strXML);
var firstname = $("firstname", xml);
alert(firstname);

Open in new window


checking :

User generated image