0

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?

This is the RSS feed XML

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>
Francesca
  • 22,178
  • 26
  • 80
  • 145
  • Check your debug console. It's likely you're seeing a same-origin policy error. See http://stackoverflow.com/questions/3206176/how-parse-remote-xml-file-with-jquery – Palpatim Jan 02 '14 at 16:10
  • @Palpatim there are no errors in the console http://www.sagittarius-digital.com/sag-aggregator/sag-aggregator.html – Francesca Jan 02 '14 at 16:13

0 Answers0