0

I have a large xml file which contains news, articles, reviews, etc. I wanna use AJAX and get only news displayed in a

<div>
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by codejoust
0
<html>
<head>
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
     <script type="text/javascript">
xmlFile = "data.xml"; /* URL of XML File. Must be on the same domain */
     $(function() {
             $.ajax({
                 type: "GET",
                 url: xmlFile, 
                 dataType: "xml",
                 success: function(xml) {
                     $('.load').hide('fast');
                     $(xml).find('div').each(function(){
                         $('<li></li>')
                             .html($(this).html());
                             .appendTo('#news');
                     });
                 }
             });
     });
     </script>
   </head>
<body>
<ul id="news">
<li class="load">Please Wait. Loading...</li>
</ul>
</body>

-- jQuery to do that...
Change the url in the script (the ajax url), and it should work.
The code was adopted from http://www.xml.com/pub/a/2007/10/10/jquery-and-xml.html
Good Luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.