Click here to Skip to main content
11,927,711 members (51,525 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


20 bookmarked

Creating An XML Newsfeed

, 29 Jul 2002
Rate this:
Please Sign up or sign in to vote.
This article explains creating an XML newsfeed in an ASP page.


Creating an XML newsfeed is a great way to get to grips with a real world use of XML. This tutorial, taken from CodeToad.Com will explain how to deal with the XML feeds offered by various sites on the web at the moment, and turn them into a useable web page. We will use a style sheet and a little ASP to do the job.

Click here to see how the final newsfeed page will look.

A full list of XML newsfeeds from is available at Amazon affiliates are also offered the chance to create their links in XML which increases the power of searches, and product placements.

We're going to use the xmlHTTP object within an ASP page to grab the XML from the URL provided by the XML-generating web site. For more information on xmlHttp see my XML HTTP Tutorial.

Once we have the XML, we call the style sheet to display the page.

Here's how the ASP page looks then :


dim objHTTP , objXML , objXSL
set objHTTP = Server.CreateObject("Microsoft.XMLHTTP") "GET", 
set objXML = objHTTP.responseXML
set objXSL=Server.CreateObject("microsoft.xmldom")


if (objXSL.parseError.errorCode = 0) then
    Response.Write "Error: " & objXSL.parseError.reason 
                     & "<br> URL:" & objXSL.url
end if

Set objHTTP = Nothing
Set objXML = Nothing
Set objXSL = Nothing

We've referenced a style sheet called style.xsl. Our XSL style sheet loops through each item in the XML and displays the record. Obviously, you'll need to look at the XML that you have and adapt the style sheet as necessary, but this should be enough to give you an idea:

<xsl:stylesheet xmlns:xsl="">
    <xsl:template match="/">

<body BGCOLOR="ffffff">

<br/> br


<DIV ALIGN="center">
                             CELLSPACING="0" WIDTH="100%">

      <xsl:for-each select="moreovernews/article">
         <TR VALIGN="middle">
           <TD ALIGN="left" BGCOLOR="ffffff">
             <xsl:attribute name="HREF">
               <xsl:value-of select="url"/>
             <xsl:attribute name="TARGET">
             <FONT FACE="Verdana, Arial,Helvetica, 
                       sans-serif" SIZE="-1" COLOR="000000">
               <xsl:value-of select="headline_text"/>
           <xsl:attribute name="HREF">
             <xsl:value-of select="document_url"/>
           <xsl:attribute name="TARGET">
           <FONT FACE="Verdana, Arial,Helvetica, 
                   sans-serif" SIZE="-2" COLOR="666666">
             <xsl:value-of select="source"/>
           <xsl:attribute name="HREF">
           <xsl:value-of select="access_registration"/>
           <xsl:attribute name="TARGET">
           <FONT FACE="Verdana, Arial,Helvetica, 
                  sans-serif" SIZE="-2" COLOR="666666">
             <xsl:value-of select="access_status"/>
         <FONT FACE="Verdana, Arial,Helvetica, 
                 sans-serif" SIZE="-2" COLOR="666666">
           <xsl:value-of select="harvest_time"/> GMT


Here's what the resulting page looks like. Remember we point to the original ASP page to do the work and pull in both the XML and the Style Sheet. Our newsfeed pulled in pop music news, so Click here for the latest popular music news.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United Kingdom United Kingdom
This script first appeared on CodeToad.Com, a developers resource of free scripts and tutorials for ASP, ASP.NET, XML, VB, DHTML, Java and other languages.

You may also be interested in...

Comments and Discussions

QuestionWhat about web components Pin
Anonymous30-Jul-02 4:30
sussAnonymous30-Jul-02 4:30 
AnswerRe: What about web components Pin
CodeToad.Com30-Jul-02 5:21
memberCodeToad.Com30-Jul-02 5:21 
AnswerRe: What about web components Pin
Ryan Johnston30-Jul-02 11:45
memberRyan Johnston30-Jul-02 11:45 
GeneralRe: What about web components Pin
Soliant30-Jul-02 13:26
memberSoliant30-Jul-02 13:26 
GeneralRe: What about web components Pin
Anonymous30-Jul-02 22:15
sussAnonymous30-Jul-02 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 30 Jul 2002
Article Copyright 2002 by CodeToad.Com
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid