Build an online RSS news aggregator with ASP.net

Source: Internet
Author: User
Tags format eval exception handling file system html page html tags net xml numeric value
asp.net|rss| Online Summary

This article explains how to use an XML WEB control to get remote XML data and display the XML data on a asp.net page, and publish the XML data in the database using the Repeater control. Over the past few years, the use of XML has exploded as demand for shared data between heterogeneous platforms has grown. Aware of this trend, Microsoft in the whole. NET Framework provides robust support for XML. This means that it has never been easier for asp.net developers to display and process XML data on a Web page. This article will learn XML and ASP.net technologies by generating a RSS2.0 aggregation engine and an online news aggregator. This article assumes that readers are familiar with ASP.net and XML.

   Brief Introduction

With the extension of office and home online time, as well as the continued explosive growth of WEB sites and accessible Internet applications, data sharing between applications is becoming increasingly important. Sharing data between heterogeneous platforms requires a platform-neutral data format that can be easily transmitted through standard Internet protocols, which is where XML comes in. Because the XML file is essentially just a text file, its coding format is well known and the existing XML parser is available to all major programming languages, so XML data can be easily used by any platform.

Web site Aggregation is an example of using XML to share data, which is often visible in news sites and blogs. Using Web site aggregation technology, Web sites can publish the latest content in XML-formatted web-accessible aggregate files. There are many kinds of aggregation formats used in Web sites, one of the most popular formats is RSS2.0. (The RSS2.0 specification is posted on the technical column of Harvard's website). In addition, MSDN Magazine has an aggregation file: MSDN Magazine: This issue, which lists articles in the latest issue of MSDN Magazine, including links to online versions of articles.

Once the Web site has a public publishing aggregation file, different clients can consume it. There are many ways to consume aggregated files, for example, a site that provides. NET technology resources may want to add the latest MSDN magazine article titles to the Web site. Aggregate files are also often used by news aggregator programs, which are specifically designed to capture and display aggregated files from different sources.

As people increasingly focus on using XML data, the ability to process XML data in asp.net pages becomes more critical than ever. Now that Web site aggregation is so important, this article will create a Web site aggregation file Builder and an online news aggregator. In creating these two micro programs, we will talk about how to access and display XML data, whether it comes from a remote Web server or a local file system. We will demonstrate how to display XML data in many different ways, such as using Repeater controls and using ASP.net XML Web controls.

   UseRSS2.0 Aggregate content of the specification

The first micro program we will create in this article is an aggregate file builder. For this mini program, suppose you are a web developer for a large news site (such as msnbc.com), and all news content is stored in a Microsoft SQL Server 2000 database. Specifically, these articles are all stored in a table named articles, and the following fields in the table are closely related to our program:

· Articleid-primary key, self-growing integer field, used to uniquely identify each article;

· title-Specify title, field data type: varchar (50);

· author-Specify author, field data type: varchar (50);

· description-News content Description, field data type: varchar (2000);

· Datepublished-News Release date, field data type: datetime

Note that there may be other fields in the articles table, which are just the fields that we use to create the aggregate file. Moreover, this is just a very simple data model, in the application of the database environment, you may use a more standardized database model, such as a separate authors (author) table, there is a creation of the author and the article a many-to-many relationship between the table and so on.

Next, we'll create a asp.net page with a formatted RSS2.0 XML file to display a list of the latest news. Before we talk about how to do this in the ASP.net page, let's introduce the content of the RSS2.0 specification. We should keep in mind that throughout the specification, RSS is designed to provide a data model for aggregating content. Then there is no doubt that it will have a series of XML elements that describe the content information that the Web site will aggregate, and a series of XML elements that describe a particular news item. Finally, don't forget that the RSS aggregation file is an XML format file that must conform to the criteria for XML formatting, namely:

• All XML elements must be nested correctly;

• All attribute values are enclosed in quotes;

<, >, and, "and" symbols to be replaced accordingly by &LT;,&GT;

Also, the XML format is case-sensitive, which means that the start and end tags of an XML element must match, and both the spelling and the capitalization must be consistent.

The root element of the RSS2.0 is the <rss> element, which can have an attribute of a version number, such as:


...

The <rss> element has only one child element <channel> that describes the content of the aggregation. There are three required child elements inside the <channel> element to describe the Web site's information. These three elements are:

title-defines the name of the aggregation file and generally includes the name of the Web site;

URL of the link-web site;

A brief description of the description-web site.

In addition, there are some optional elements to describe the site information. For more information on these elements, see the RSS2.0 specification.

Each news item is placed in a separate <item> element. The <channel> element can have any number of <item> elements. Each <item> element can have a variety of child elements, and the only requirement is that at least one of the <title> elements and <description> elements must be included as child elements. Some of the related <item> child elements are listed below:

Title of title-news item;

link-The URL of the news item;

description-The outline of the news project;

author-, author of the News project;

Release date of pubdate-news item

The following is a very simple RSS2.0 aggregation file. You can see examples of other RSS2.0 files from RSS generated by Radio userland.



Latest datawebcontrols.com FAQs
http://datawebcontrols.com

This is the syndication feeds for the FAQs
At datawebcontrols.com


Working with the DataGrid
http://datawebcontrols.com/faqs/DataGrid.aspx
Mon, 2003 21:00:00 GMT


Working with the Repeater

This is article examines how to work with the Repeater
Control.

http://datawebcontrols.com/faqs/Repeater.aspx
Tue 2003 12:00:00 GMT




There is something particularly important about the format of the <pubDate> element, and let's talk about it. The RSS request date must be formatted according to the RFC822 date and time specification, which starts with an optional 3-letter week abbreviation plus a comma, followed by a 3-letter month and year, and then a time zone name. Also, note that the <description> child elements are optional: The first news in the above file does not have a <description> element, and the second news is one.

   aggregate content by asp.net page output

Now that we know how to store our news items in accordance with the RSS2.0 specification, we are ready to create a ASP.net page that will return the content of the site aggregation when the user makes the request. Rather, we'll create a asp.net page called rss.aspx, which returns the latest 5 news items from the Articles database table in the RSS2.0 specification format.

There are several ways to do this, which will be mentioned later. But now, the first thing we have to do is to get the latest 5 news items from the database. This can be obtained by using the following SQL query statement:

SELECT Top 5 articleid,title,author,description,datepublished from Articles order by datepublished DESC

Having obtained this information, we need to convert this information into the corresponding RSS2.0 format aggregation file. The simplest and fastest way to display the database data as XML data is to use the Repeater control. Precisely, the Repeater control will display <rss> elements, <channel> elements, and site-related element tags in the HeaderTemplate and FooterTemplate templates, displaying the <item> element in the ItemTemplate template. Here is the HTML section of our asp.net page (. aspx file):

<%@ Page language= "C #" contenttype= "Text/xml" codebehind= "Rss.aspx.cs"
Autoeventwireup= "false" inherits= "Syndicationdemo.rss"%>
<asp:repeater id= "Rptrss" runat= "Server"
<HeaderTemplate>
<rss version= "2.0" >
<channel>
<title> asp.net news! </title>
<link> http://www.ASPNETNews.com/Headlines/</link>
<description>
This is the syndication feeds for aspnetnews.com.
</description>
</HeaderTemplate>

<ItemTemplate>
<item>
<title> <%# formatforxml (DataBinder.Eval (Container.DataItem,
"Title")%> </title>
<description>
<%# Formatforxml (DataBinder.Eval (Container.DataItem,
"Description")%>
</description>
<link>
http://www.aspnetnews.com/story.aspx?id=<%#
DataBinder.Eval (Container.DataItem, "ArticleID")%>
</link>
<author> <%# formatforxml (DataBinder.Eval (Container.DataItem,
"Author")%> </author>
<pubDate>
<%# String.Format ("{0:r}"),
DataBinder.Eval (Container.DataItem,
"Datepublished")%>
</pubDate>
</item>
</ItemTemplate>

<FooterTemplate>
</channel>
</rss>
</FooterTemplate>
</asp:Repeater>

The first thing to note is that the above code example includes only Repeater controls, no other HTML tags or Web controls. This is because we want the page to output only XML-formatted data. In fact, if you look at the @Page instructions, you'll see that ContentType is set to the XML MIME type (text/xml). The second thing to note is that in the ItemTemplate template, when you add the database fields title, Description, and Author to the XML output, we call the auxiliary function Formatforxml (). We will soon see that the function is defined in a class that is encoded in the background, and its role is simply to replace the illegal XML characters with their corresponding legitimate escape characters. Finally, we should note that the database fields inside the <pubDate> element datepublished are formatted with String.Format. The standard format descriptor "R" formats the datepublished value appropriately.

The background coding class code for this Web page is not complex. The Page_Load event handler simply binds the results of the database query to the Repeater control, and the Formatforxml () function makes some simple string substitutions as needed. For simplicity's sake, the following example lists only the code for these two functions:

A screenshot of the rss.aspx page is accessed in the browser. Tuyi.


Figure one Access Rss.aspx page through the browser


Before we generate an online news aggregator, let me talk about some possible enhancements to this aggregation engine. First, every time you visit the rss.aspx page, you have to access the database once. If a large number of people are expected to visit rss.aspx pages frequently, it is valuable to use output caching. Second, the news site usually divides the aggregated content into different categories. For example, News.com has a number of specialized aggregate content areas, such as enterprise computing, E-commerce, communication content, and so on. This support can be easily provided by adding a Category field that represents a category in the database table articles. In this way, in the Rss.aspx page, you can receive a query parameter that represents the display category, and then search only for the specified news item category.

  Use aggregation summary in asp.net pages

To test the aggregation engine we just built, we'll create an online news aggregator that allows you to collect any number of aggregated content summaries. The interface of the aggregator is simple, see figure two. It includes three frames pages. The left frame lists the different aggregate content summaries in a list format. The upper right frame displays the news items that are included in the selected aggregate content summary and links to view the news item. Finally, in the lower-right frame, the selected news item title and content are displayed. Incidentally, such interfaces are essentially a standard interface for various types of aggregators, including news aggregators, email client software, and newsgroup readers.


Figure II News aggregator user interface screenshot

The first step is to create an HTML page to build the framework user interface. Fortunately, in Visual Studio.NET 2003, this is a very easy process. You only need to add a new project to the Web application solution and select the new project type as Frameset. (I named this new file newsaggregator.htm in my project.) I set it to an HTML file instead of a asp.net page because this page includes only the HTML code that creates the frame. Each individual frame will display a asp.net page). Next, see figure Three, the Frameset Template Wizard starts, simply selects the option "Nested hierarchy" and then presses the OK button.


Figure three VS2003 Frameset Template Wizard screen

The Frameset Template Wizard then creates an HTML page that already contains the source code for the frame. As long as the Src property of the left frame is set to displayfeeds.aspx, it is the URL of the list display aggregation summary asp.net page. The newsaggreator.htm page is complete.

In the following three sections, we will show you how to create the three components of the online news aggregator, which is the displayfeeds.aspx that displays the aggregated summary list, which displays the specific aggregation summary news item. Displaynewsitems.aspx and displays the displayitem.aspx for specific content of specific news items for the specified aggregation summary.

   Show aggregation Summary list

Now we need to create the Displayfeeds.aspx page. This page displays a list of aggregated summaries for subscriptions. As a demonstration, I put these aggregation summaries in a database table called Feeds. Of course, you can also put them in an XML file. Table Feeds has the following four fields:

· Feedid-primary key, self-growing integer type, uniquely labeled a summary

· title-Summary name, database field type: varchar (50)

· URL of the Url-rss Digest, database field type: varchar (150)

· updateinterval-Summary update frequency (minutes), database field type: int

The Displayfeeds.aspx page uses a DataGrid control to display a list of aggregation summaries. This DataGrid has only one hyperlinkcolumn column that displays the contents of the Title field and links to the Displaynewsitems.aspx page, passing the value of the Feedid field in the query string. The following is the declaration of the DataGrid control, which omits some extraneous parts for simplicity:

autogeneratecolumns= "False" ... >
...

Datanavigateurlfield= "Feedid"
Datanavigateurlformatstring= "Displaynewsitems.aspx?" FEEDID={0} "
Datatextfield= "Title" headertext= "RSS Feeds"



The key to note here is the definition of the HyperLinkColumn column. Its Target property is set to the name of the upper-right frame, so that when the user clicks, the displaynewsitems.aspx page appears in the frame in the upper-right section. In addition, the properties Datanavigateurlfield, Datanavigateurlformatstring, and DataTextField are set so that hyperlinks display the title of the summary, and when clicked, the user is brought to the Displaynewsitems.aspx the page and passes the contents of the Feedid field to the query string. (The Background code class for this page accesses only the summary list from the Feeds table, returns in alphabetical order in the Title field, and then binds the query results to the DataGrid control.) Because of the space limit, this article does not list the code here. )

   Show news items for a specific aggregation summary

The next task we face is to create a displaynewsitems.aspx page. This page displays the news item title of the selected aggregation summary as a link, and when the title is clicked, the content of the news is displayed in the frame in the lower-right section. To complete this task, we will face the following two major challenges:

• Access RSS aggregation summaries through the specified URL;

• Converts the received XML data to the appropriate HTML;

Fortunately, in the. NET framework, it is not difficult to achieve both tasks. For the first task, you need only two lines of code, and we can load the remote XML data into a XmlDocument object. The second task, however, is also easier to display XML data in a ASP.net page with the help of ASP.net XML Web controls.

An XML Web control is designed to display raw or converted XML data in a Web page. The first step in using an XML WEB control is to define an XML data source that can be done in many ways by defining a series of properties. Using the document property, you can specify a XmlDocument instance as an XML data source for an XML Web control. If the XML data exists in a file on the Web server file system, you can use the DocumentSource property as long as the relative or absolute path to the XML file is provided. Finally, if your XML data is a string, you can assign the contents of this string to the Documentcontent property of the control. All three of these methods can relate XML data to XML controls.

Typically, before you display XML data to a Web page, we transform the XML data in some way. The XML Web control allows us to specify an XSLT stylesheet to do this transformation work. Like XML data, an XSLT stylesheet can be set in one of two different ways by two properties, one of which is that the Transform property can be assigned to the XslTransform instance, and the second is to give the relative or absolute path of the XSLT file on the local WEB server Trans Formsource property.

Now we're going to create the displaynewsitems.aspx page. Before adding an XML Web control and writing a background code class, we need to add a small piece of client JavaScript code to the HTML section. To be exact, add the following <script> code block to the


This client JavaScript code displays a blank page in the frame in the lower-right corner whenever the Displaynewsitems.aspx page is loaded. To understand why we want to add this code, let's look at what happens when we omit this code:

• Users click on the aggregation summary in the left frame, and the browser loads the summary news item in the upper right frame;

• The user clicks on a news item in the upper right frame, and the browser loads the details of the news item in the lower right frame;

Now the user clicks the other aggregation summary in the frame on the left, and the browser loads the new summary news item in the frame on the upper right-hand part;

The details of the previous news item are also shown in the bottom right frame! With the client Javascript code above, each click on the summary of the left frame clears the contents of the lower right frame to remove the flaw.

After we've dealt with the problem with client code, let's turn our attention to adding XML Web controls. Once you have joined the XML Web control, set its ID property to the Xsltnewsitems,transformsourc property set to Newsitems.xslt (the name of the XSLT style sheet file that we will create). Now, in the Page_Load event handler, we need to get the remote RSS aggregation file in a XmlDocument instance, and then assign the document property of the XML Web control to the XmlDocument instance.

In the Page_Load event handler, the code that is closely related to the task we are implementing is the last three lines of code. These three lines of code create a new XmlDocument object, load the remote RSS Digest content, and then assign the XmlDocument object to the Document property of the XML Web control. To access remote XML data and display them on ASP.net pages is that simple, does not impress you?

The only thing left to do is to create an XSLT stylesheet, newsitems.aspx. The following is a draft of the first version of the style sheet:

Xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" >


disable-output-escaping= "Yes"/>




  • Displayitem.aspx?id=

    rbottom
    disable-output-escaping= "Yes"/>

    ( )




  • This XSLT stylesheet has only one template for matching "/rss/channel" XPath expressions. This template first displays the contents of the <title> element in bold. Then, loop through each <item> element, and for each element, display a hyperlink to the Displayitem.aspx page that passes the position attribute of the <item> element in the query string. Be aware that the target property of the hyperlink is set to Rbottom, the name of the bottom right frame. Finally, the title and <pubDate> elements of each news item are displayed.

    There are two items in the XSLT stylesheet that are not familiar to everyone. The first is the disable-output-escaping= "yes" attribute in the <xsl:value-of> element. Essentially, the setting of this property notifies the XSLT engine not to escape those illegal XML characters, such as: ",", "," and ". To understand the meaning of this setting, it is important to know that if you do not set this property (that is, set to the default value "No"), if the caption contains an escaped & character, then there will be an ampersand in the output HTML file, not just a character &. If you think about it a second, you will find that this situation can lead to a lot of problems. For example, suppose that the title of an aggregate file is "Matt ' s <i>Cool</i> blog", and if the output escape is not blocked, then the output will remain "Matt ' s <i>Cool</i> blog", The Web page will be displayed as "Matt's" <i> Cool </i> Blog. When you disable output escaping with the disable-output-escaping= "yes" setting, the output is not escaped, and the above content is treated as "Matt" 's <i> Cool </i> Blog, which is displayed on the page as "Matt" cool Blog. "

    Another note is the element <a>. This strange syntax generates the following output:

    news item title

    The reason to use this syntax is to add an attribute to the element you want to create in the XSLT stylesheet, and then use the <xsl:attribute> syntax in the label for that element. Some examples of this syntax can be found on the W3Schools Web site: the <xsl:attribute> Element.

    Finally, note that the value of the ID query string for the hyperlink is from the <xsl:number> element, the value returned from the position () function. The <xsl:number> element simply outputs a numeric value. The position () function is an XPath function that returns the ordinal position of the current node in an XML document. This means that for the first news item, the position () function returns 1, the second news item, the POSITION function returns 2, and so on. We need to record this value and pass it through the query string. This way, when the displayitem.asp page is accessed, you can know what items show RSS aggregation summaries.

    Smart readers may have noticed that our XSLT stylesheet is not complete, because the Feedid parameter is not passed through the query string to the Displayitem.aspx page. To understand why, let's recap, in the ID query string parameter, the sequence number of the <item> element to which the user intends to view the details is passed. That is, if the user clicks on the fourth news item, the page displayitem.aspx?id=4 will be loaded into the frame in the lower-right section. The problem is that the Displayitem.aspx page cannot determine which summary the user wants to see. There are two different ways to solve this problem, such as reading the URL of the upper right frame with client-side Javascript code in the right lower frame, and then determining the value of the Feedid. In my opinion, the simpler approach is to pass the Feedid value through the query string along with the ID parameter.

    In this case, one of the challenges is that the XSLT stylesheet manipulates the RSS XML data without feedid values. But the displaynewsitems.aspx page knows the Feedid value and needs a way to make the XSLT stylesheet aware of this value. You can accomplish this by using the XSLT parameter.

    The use of XSLT parameters is very simple. In the XSLT stylesheet, you need to add a <xsl:param> element to the <xsl:template> element that provides the name of the parameter. The following code names this parameter feedid:




    ...


    You can now use this argument in the <xsl:value-of> element with the following syntax:


    Finally, by adding the following code to our XSLT stylesheet, we can add the Feedid query string parameter to the hyperlink:


    displayitem.aspx?id= &feedid= />


    Note After the ID query string parameter we have added A & character (escape &) so that we can pass the value of the Feedid parameter to the Feedid parameter of the query string. That's what we're going to add to the XSLT style sheet.

    The rest of the work is to set the value of this parameter in the Page_Load event handler of the Displaynewsitems.aspx page. This work can be done by using the XsltArgumentList class. This class has a addparameter () method. Once we create an instance of this class and add the corresponding argument, we can assign the instance to the Transformargumentlist parameter of the XML Web control. The following code shows the updated Displaynewsitems.aspx page Page_Load event handler function:

       Show details of a particular news item

    The last thing left to do is to display the details of the specific news item selected by the user. These details will appear in the lower-right frame and will display information such as the title of the news item, the description, and the link to the news item. Like the Displaynewsitem.aspx page, the displayitem.aspx page first obtains a remote RSS aggregation summary based on the incoming Feedid query string parameter, and then it displays the details with an XML Web control. In fact, the Page_Load event handler for the Displayitem.aspx page is almost the same as the Displaynewsitem.aspx page, with only the following two small differences:

    · The displayitem.aspx page needs to read the value of the ID query string parameter;

    · The Displayitem.aspx page uses an XSLT parameter, but this parameter is not the same as the parameter used for the displaynewsitem.aspx page;

    Displaynewsitem.aspx and displayitem.aspx pages need to pass an XSLT style sheet in the parameters. The Displaynewsitem.aspx page passes the parameter feedid, and displayitem.aspx also needs to pass in the ID parameter, which means that the XSLT stylesheet should display that news item. This small difference is shown in bold in the following code, and the following code omits the same part as the Displaynewsitems.aspx page:

    The following is an XSLT style sheet that transforms XML data:

    Xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" >



    disable-output-escaping= "Yes"/>


    disable-output-escaping= "Yes"/>



    select= "item[$ID]/link"/>
    _blank
    Read More ...



    Note The <xsl:param> element is used to declare the ID XSLT parameter. Then, in several different <xsl:value-of> elements, the ID parameter is used to grab a specific <item> element from the list of <item> elements. In XPath syntax, elementname[i] means accessing the first element based on the corresponding element name. For example, Item[1] takes only the first <item> element, Item[2] Gets the second element. So the item[$ID] is to get the specific <item> element defined by the XSLT parameter ID.

    Finally, it is worth noting that the hyperlinks in the style sheet near the end of Read more ..., its target property is set to NULL, so that when the user clicks Read more ... Link, the browser opens a new window.

       future extensions and shortcomings of the current program

    One obvious drawback of the code described in this article is that each time a user clicks on an aggregation summary from the left frame or clicks on a news item in the upper right frame, the remote aggregation digest is loaded and parsed. Every time a user clicks on a remote aggregation summary, all the items are loaded, and the efficiency is certainly poor. Reloading the entire remote aggregation summary is also a waste of resources each time a user clicks on a news item title. This approach is not only inefficient, but also impolite to the individuals or companies that provide the publishing service because these sequential, unnecessary requests take up the load resources of their WEB servers.

    This shortcoming has been solved in the source code accompanying this article. Specifically,. NET data caching can be used to hold XmlDocument objects with different summaries. The cache interval is set to the value defined by the UpdateInterval field in Datasheet Feeds. (Of course, for some reason, the XmlDocument object of the digest may be cleared out of the cache in advance)

    Another disadvantage of this system is that there is no state preservation between the right upper frame and the lower right frame. To illustrate what is causing the problem, consider the following actions:

    • Users click on an aggregation summary link in the left frame to load the summary's news item in the upper-right frame. Assuming that the updateinterval value of this digest is 30, it means that the content expires after 30 minutes;

    • While loading the news items of the upper right frame, these contents are cached;

    • Users leave to have lunch;

    • A new news item is added to the website that publishes aggregated content;

    • Our users are back after lunch for one hours, and the XmlDocument cache for this digest has expired;

    • The user clicks on the first news item of the upper right frame, will load displayitem.aspx in the lower right part frame, incoming ID parameter value 1;

    · The Displayitem.aspx page did not find the XmlDocument object in the cache and had to retrieve the remote summary again. This will result in new data (don't forget, step 4 has added a new news item), and then this page will display the first news item (because the value of the ID parameter is 1);

    • The user sees the new news item, but the content makes him feel a bit confused because it's not the one he clicked on, and the new story doesn't appear on the top right.

    This problem occurs because the ID parameter does not uniquely identify a news item, it is just an offset from the list of news items at a specific point in time. A good way to solve this problem is not to use data caching to save aggregation summaries, but rather to use a database or other means of persistent media (such as an XML file for a WEB server's local file system). If you use a database, each news item can have a unique identification number that can be used to pass to the bottom right corner of the frame. This approach can ensure that the problems mentioned above are resolved. Of course, it also increases the complexity of the system, such as deciding when to purge old news items from the database.

    The existing applications in this article are still missing exception handling, which must be added. Especially when fetching data from a remote RSS aggregation summary file and loading it into a XmlDocument object, you should add exception handling. Because the remote file may not exist or is not in the correct format.

    There are many enhancements that you can easily add to this online news aggregator. An obvious feature is the need for an admin page to allow users to add, delete, and edit their current aggregation summaries. Also, if you can allow users to customize the categories, it's better to put their aggregation summaries together by category. In addition, the current user interface is relatively rough, but it is easy to beautify the interface by adding HTML code generated by some XSLT stylesheets or by adding some style sheets to several frameworks. Finally, adding some <meta> elements to the HTML tag allows the upper right frame to refresh periodically, allowing the user to see the latest news items without manually refreshing the page.

    Note (August 4, 2003): After this article was published, some readers told me by Email that there are two potential problems when displaying <description> elements for a particular RSS aggregation item:

    1, the Disable-output-encoding property, this property is used in the <xsl:value-of> element, but not all XSLT parsers implement this functionality. The. NET XSLT Parser supports Disable-output-encoding, but keep in mind, as readers may try to migrate the application to other platforms.

    2, the HTML content of the <description> element is exported unaltered. However, these HTML content may contain malicious code, such as <script> or <embed> code blocks. Ideally, the code should be removed. To clear out these potentially dangerous code, you might need to use some extension functions (see Extending XSLT with JScript, C #, and Visual Basic.) NET). To see more information about removing HTML content from RSS aggregation summaries, see the ' Dive into Mark ' log.

       Summary

    In this article, we not only talked about how to create an aggregation engine, but also created an online news aggregator. In building these two applications, we used the technique of displaying XML data on asp.net pages. Within the aggregation engine, we used the Repeater control to display the data in the database in XML format. And in the news aggregator, we used XML Web controls and XSLT style sheets.

    I invite you to download the online news aggregator for this article and then enhance it according to your needs. If you have any questions about the application or the conceptual aspects of this article, be ready to EMail you. My EMail is mitchell@4guysfromrolla.com.



    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.