I have been learning. Net for a while and have made some small things. It seems naive now. I haven't stayed up for a long time, and I'm not used to it. This evening, we are engaged in the XML data display of RSS. I also hope to communicate with you. You can customize the XML document address to be displayed and the number of records displayed.
Source code: Demo address http://shiyan3-1.at.vwdhosting.net/all source code: Download
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;
}
}
}