How to parse XML with jQuery

/* ------- XML <?xml version="1.0" ?> <result> <item> <id>1</id> <title>title1</title> <description>desc1</description> </item> <item> <id>2</id> <title>title2</title> <description>desc2</description> </item> <!-- ... --> </result> */ $.get('file.xml',{},function(data){ $('item',data).each(function(){ var $this = $(this); var id = $this.find('id').text(); var title = $this.find('title').text(); var description = $this.find('description').text(); //do something ... }); });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.