源码: 演示地址http://shiyan3-1.at.vwdhosting.net/ 所有源码:下载
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class rss : System.Web.UI.UserControl
{
private string url1="rss/1.xml";
private int sl1=10;
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument xml1 = new XmlDocument();
xml1.Load(Server.MapPath(url1));
XmlNodeList kk = xml1.DocumentElement.ChildNodes[0].SelectNodes("item");
Label1.Text = "<ul style='margin-left:15px;'>";
for (int k = 0; k < sl1; k++)
{
string ss = "";
if (kk.Item(k).ChildNodes[0].InnerText.Length >= 30)
{
ss = kk.Item(k).ChildNodes[0].InnerText.Substring(0, 30);
}
else
{
ss = kk.Item(k).ChildNodes[0].InnerText;
}
Label1.Text += "<li><a href=" + kk.Item(k).ChildNodes[1].InnerText + " title='"+kk.Item(k).ChildNodes[0].InnerText+"'>" + ss + "</a></li>";
}
Label1.Text += "<ul>";
}
public string url
{
set
{
url1 = value;
}
}
public int sl
{
set
{
sl1 = value;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class rss : System.Web.UI.UserControl
{
private string url1="rss/1.xml";
private int sl1=10;
protected void Page_Load(object sender, EventArgs e)
{
XmlDocument xml1 = new XmlDocument();
xml1.Load(Server.MapPath(url1));
XmlNodeList kk = xml1.DocumentElement.ChildNodes[0].SelectNodes("item");
Label1.Text = "<ul style='margin-left:15px;'>";
for (int k = 0; k < sl1; k++)
{
string ss = "";
if (kk.Item(k).ChildNodes[0].InnerText.Length >= 30)
{
ss = kk.Item(k).ChildNodes[0].InnerText.Substring(0, 30);
}
else
{
ss = kk.Item(k).ChildNodes[0].InnerText;
}
Label1.Text += "<li><a href=" + kk.Item(k).ChildNodes[1].InnerText + " title='"+kk.Item(k).ChildNodes[0].InnerText+"'>" + ss + "</a></li>";
}
Label1.Text += "<ul>";
}
public string url
{
set
{
url1 = value;
}
}
public int sl
{
set
{
sl1 = value;
}
}
}