News.com XML – RSS feed

[Total: 0    Average: 0/5]

This script allows you to have RSS news feeds displayed on your web site without the need for CGI or server side scripting.

Head Code:

<SCRIPT LANGUAGE=JavaScript> 

// Helper function that generates an HTML <TABLE> element to display the list of news items 

function getrss(rsslink) { 
var newxml = document.createElement("XML"); 
newxml.async = false; 
newxml.load(rsslink); 

var sitetitle=newxml.selectNodes( "//channel" ).item( 0 ).selectSingleNode( "title" ).text 
var strHTML = "<TABLE><TH style='font-size: 12;'>"+sitetitle+"</TH><tr>"; 

var newsitems = newxml.selectNodes( "//item" ); 

// Walk the list of <items> nodes to generate the appropriate HTML 
for( var i = 0; i < newsitems.length; i++ ) { 


strHTML += "<td style='font-size: 12;'><a href='"+newsitems.item( i ).selectSingleNode( "link" ).text +"' "; 
strHTML += " title='"+ newsitems.item( i ).selectSingleNode( "description" ).text + "'>"; 
strHTML += newsitems.item( i ).selectSingleNode( "title" ).text + "</a></td>"; 
strHTML += "</TR>"; 
} 

strHTML += "</TABLE>"; 
return strHTML; 
} 
</SCRIPT> 

Body Code:

<DIV ID="Newsdotcomrss" ></DIV> 

<script>
document.getElementById("Newsdotcomrss").innerHTML=getrss('http://rss.com.com/2547-12-0-5.xml');
</script>

Times Viewed: 9

Leave a Reply

Your email address will not be published. Required fields are marked *