My Asp.net 2.0 rsss display

Source: Internet
Author: User
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;
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.