Thread: XML AND JQUERY
View Single Post
  #2 (permalink)  
Old July 8th, 2009, 02:51 PM
samjudson's Avatar
samjudson samjudson is offline
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

text[0] returns a DOMElement, so the method text() does not exist on it. To get access to the text() method you would need either iterate over the nodes using .each() or wrap the new DOMElement in the jquery code:

Code:
$(document).ready(function() {
           $.get("labels.xml", function(xml) {
                 var nodes= $("name", xml);
                 $("div#xml").html("<Names>" + $(nodes[0]).text() + "</Names>");
           });
 });
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
Reply With Quote