lundi 12 mai 2014

find a node value in xml using jQuery


Vote count:

0




Excuse the simple question: I'm fairly new to JQuery!


I have a variable named xmlText containing an XML string chunk where I'm sure that there is only one node of type "node1", and so on.



<root><node1>value1</node1><node2>value2</node2></root>


Using JQuery I can access the value of a given node like this:



$('root node1', xmlText).each(function () {
alert($(this).text();


});


How can I access the value witout a ".each(function()" construct?


Notice the xmltext variable is just a text chunk, xml like formated, not a complete well formated xml file nor a parsed DOM object.



asked 41 secs ago






Aucun commentaire:

Enregistrer un commentaire