Parse XML to ordered list

Parse XML to ordered list

I'm using the following code to parse my XML document into an unordered list.  When the code complete's, I get "undefined" in both my hyperlink and text field.  Below is an example of my XML and my HTML.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  3.   <channel>
  4.     <title>News Feed 2</title>
  5.     <link>http://my.test.site.io/</link>
  6.     <description>News Feed 2</description>
  7.     <pubDate>Fri, 22 Feb 2013 16:59:11 GMT</pubDate>
  8.     <dc:date>2013-02-22T16:59:11Z</dc:date>
  9.     <item>
  10.       <title>Test 1</title>
  11.       <link>http://my.test.site.io/</link>
  12.       <pubDate>Wed, 16 Jan 2013 22:29:39 GMT</pubDate>
  13.       <guid>http://my.test.site.io/</guid>
  14.       <dc:date>2013-01-16T22:29:39Z</dc:date>
  15.     </item>
  16.     <item>
  17.       <title>Test 2</title>
  18.       <link>http://my.test.site.io/</link>
  19.       <pubDate>Thu, 03 Jan 2013 22:09:24 GMT</pubDate>
  20.       <guid>http://my.test.site.io/</guid>
  21.       <dc:date>2013-01-03T22:09:24Z</dc:date>
  22.     </item>
  23.     <item>
  24.       <title>Test 3</title>
  25.       <link>http://my.test.site.io/</link>
  26.       <pubDate>Thu, 03 Jan 2013 22:09:24 GMT</pubDate>
  27.       <guid>http://my.test.site.io/</guid>
  28.       <dc:date>2013-01-03T22:09:24Z</dc:date>
  29.     </item>
  30.     <item>
  31.       <title>Test 4</title>
  32.       <link>http://my.test.site.io/</link>
  33.       <pubDate>Thu, 03 Jan 2013 22:09:24 GMT</pubDate>
  34.       <guid>http://my.test.site.io/</guid>
  35.       <dc:date>2013-01-03T22:09:24Z</dc:date>
  36.     </item>
  37.     <item>
  38.       <title>Test 5</title>
  39.       <link>http://my.test.site.io/</link>
  40.       <pubDate>Thu, 03 Jan 2013 22:09:24 GMT</pubDate>
  41.       <guid>http://my.test.site.io/</guid>
  42.       <dc:date>2013-01-03T22:09:24Z</dc:date>
  43.     </item>
  44.     <item>
  45.       <title>Test 6</title>
  46.       <link>http://my.test.site.io/</link>
  47.       <pubDate>Thu, 03 Jan 2013 22:09:24 GMT</pubDate>
  48.       <guid>http://my.test.site.io/</guid>
  49.       <dc:date>2013-01-03T22:09:24Z</dc:date>
  50.     </item>
  51.   </channel>
  52. </rss>

Here is my current HTML page

  1. <html>
  2. <head>
  3. <title>Test News Feed</title>
  4. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
  5. <script type="text/javascript">
  6. $(document).ready(function()
  7. {
  8. $.ajax({
  9. type: "GET",
  10. url: "10.0.8.10/feeds/rss/news-feed-2/",
  11. dataType: "xml",
  12. success: function(xml) { parseXml(xml); }
  13. });
  14. });

  15. function parseXml(xml)
  16. {
  17. $(xml).find("item").each(function()
  18. {
  19. $("#news").append("<li><a href='" + $(this).attr("link") + "'>" + $(this).attr("title") + "</a></li>");
  20. });
  21. }
  22. </script>
  23. </head>
  24. <body>
  25. <div>
  26. <ul id="news"></ul>
  27. </div>
  28. </body>
  29. </html>
Also,  how would I modify the function parseXml to only show the 5 most recent items.