1、通过XmlDocument类实现RSS信息获取

/// 
/// 获得要显示的Feed种子数据
/// 
/// 
/// 
/// 
public string LoadRSS(string RssUrl, int showNewsCount)
{
string strRssList = "";
string strMsg;
try
{
XmlDocument objXMLDoc = new XmlDocument();
objXMLDoc.Load(RssUrl); //加载XML文档
XmlNodeList objItems = objXMLDoc.GetElementsByTagName("item");//获取所有匹配的元素
if (showNewsCount > 30)
showNewsCount = 10; //只显示10条记录
if (showNewsCount < 1)
showNewsCount = objItems.Count;
string title = "";
string link = "";
int i;
if (objXMLDoc.HasChildNodes == true) //该文档有子节点
{
i = 1;
foreach (XmlNode objNode in objItems) //循环所有元素
{
if (i <= showNewsCount)
{
if (objNode.HasChildNodes == true)
{
XmlNodeList objItemsChild = objNode.ChildNodes; //得到当前元素的所有子节点
foreach (XmlNode objNodeChild in objItemsChild)
{
switch (objNodeChild.Name)
{
case "title":
title = objNodeChild.InnerText;
break;
case "link":
link = objNodeChild.InnerText;
break;
}
}
i = i + 1;
strRssList += "" + title + "
"; } } } } strMsg = strRssList; } catch { strMsg = "RSS Feed 源数据出错!"; } return strMsg; }

2、通过XMLHTTP无刷新更新在线RSS阅读获取




无刷新动态更新的在线RSS阅读获取