Is it possible to pull data from items on an XML file and store them as objects in jQuery which can then be cycled through?
I want to store the following data from each item:
- title
- description
- pubdate
- link
- category
And then output as HTML like this (for the time being):
<ul>
<li>title</li>
<li>description</li>
<li>pubdate</li>
<li>link</li>
<li>category</li>
</ul>
I have this code as a start but it does nothing:
<script>
$.ajax({
url:'http://www.sagittarius-digital.com/news.rss',
dataType:'xml',
success:function( xmlString ){
var xmlDoc = $.parseXML( xmlString ),
$xml = $( xmlDoc ),
$title = $xml.find( "title" );
// Append "RSS Title" to #someElement
$( "#someElement" ).append( $title.text() );
// Change the title to "XML Title"
$title.text( "XML Title" );
// Append "XML Title" to #anotherElement
$( "#anotherElement" ).append( $title.text() );
}
});
</script>
A sample item
<item>
<title>Building Bridges Between Technology And People</title>
<description>
Sagittarius has been appointed by the Rochester Bridge Trust as an approved supplier and technology partner to provide assistance to the Trust in 2014.
</description>
<link>
http://www.sagittarius-digital.com/News/our-news/building-bridges-between-technology-and-people.aspx
</link>
<pubDate>Mon, 16 Dec 2013 11:00:00 GMT</pubDate>
<guid>
http://www.sagittarius-digital.com/pages/news/latest_news_detail.aspx?nid=5607
</guid>
<category>Our News</category>
</item>