Thread: XML AND JQUERY
View Single Post
  #7 (permalink)  
Old July 9th, 2009, 10:36 AM
pallone pallone is offline
Friend of Wrox
Points: 1,243, Level: 13
Points: 1,243, Level: 13 Points: 1,243, Level: 13 Points: 1,243, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default XML AND JQUERY

Hi samjudson,

Based on your sample code and suggestions I have tried the code below but it is not working as expected. It gets the text of the address element but not the xml.

I have tried to remove the text() method call but to no avail

location.append($(this).text());

location.append($(this));

Could you please shed some light on how to get the xml of an object in JQUERY?

$(document).ready(function() {
$.get("labels.xml", function(xml) {
var nodes = $("address", xml);
var location = $("<Location/>");

$(nodes).each(function() {
location.append($(this).text());
//location.append($(this));
});

$("div#xml").append(location );
});
});


This is what this code is producing:

<location>

45 Usura Place Hailey ID 3 Prufrock Lane Stamford CT 10 Bridge Tunnel Harlem NY 7 Heaven's Gate Idoto Anambra

</location>

I am looking forward to your reply.

Cheers,

C
Reply With Quote