Hi there!
I'm trying to load & read directly with jQuery.ajax an XML file.
Here is the code I'm using:
- function readXMLNews(xml)
- {
- $(xml).find('news').each(function(){
-
- var $newsHeader = $('div#newsHeader');
- var $newsBody = $('div#newsBody');
- var $newsFoot = $('div#newsFoot');
-
- var $nodeHead = $(this).find('header');
- var $nodeBody = $(this).find('body');
- var $nodeDate = $(this).find('date');
- var $nodeBy = $(this).find('by');
-
- $newsHeader.text($nodeHead.text());
- $newsBody.text($nodeBody.text());
- $newsFoot.text('By: ' + $nodeBy.text() + ' - ' + $nodeDate.text());
- });
- }
- $(document).ready(function(){
- $.ajax({
- type: "GET",
- url: '../news/20120901.xml',
- dataType: 'xml',
- success: function(xml){readXMLNews(xml)},
- error: alert('error')
- });
- });
- I didn't know it was imposible, so far I wouldn't had achieved it. -