ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || RAM 
Search Site:

Home » XML » Article

Creating An XML Newsfeed

Article by:  Jeff Anderson  ( 1362 ) (5/23/2002)
Bookmark us now! Add to Favourites
Email a friend!Tell a friend
Summary: A full explanation of how to take an XML newsfeed from moreover, amazon affiliates, google or any of the other current feed providers, and turn it into a display page using a little ASP.
Viewed: 38907 times Rating (54 votes): 
 4.8 out of 5
 Rate this Article  Read Comments  Post Comments

Creating an XML newsfeed is a great way to get to grips with a real world use of XML. This tutorial 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 our 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", "", false
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 display 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">


<DIV ALIGN="center">

      <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

For Beginners, the Wrox Beginning XML is a real must :

Beginning XML Click here to Buy!

"Beginning XML provides a complete course in the Extensible Markup Language (XML) with an unusually gradual learning curve. In fact, the introduction states that the book is "for people who know that it would be a pretty good idea to learn the language, but aren't 100 percent sure why." "

If you need a general XML reference guide, we can't recommend this book enough:

XML in a Nutshell : A Desktop Quick Reference (Nutshell Handbook) Click here to Buy!
"Continuing in the tradition of the Nutshell series, XML in a Nutshell provides a dense tutorial on its subject, as well as a useful day-to-day reference. While the reader isn't expected to have prior expertise in XML, this book is most effective as an add-on to a more introductory tutorial."

Useful Links

CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Creating An XML Newsfeed'
XML and JavaScript Tutorial
by Premshree Pillai
This tutorial shows how we can use XML and client side JavaScript. We will see how we can display the contents of a XML file using JavaScript, accessing child elements, manipulating elements etc.
Display XML in tree format using Javascript
by Premshree Pillai
In this article, I present a XML based client-side JavaScript that reads data from an external XML file, traverses the XML data and displays the same in a tree format. I'll use the XMLDOM ActiveX object built into Microsoft Internet Explorer for the same.
Pulling Data from Other Web pages with XMLHTTP
by Jeff Anderson
Using the little known (as yet) XMLHTTP object, part of the XML DOM Model, you can pull data from other web pages for manipulation or your own purposes.
Using the XML Data Source Object
by Premshree Pillai
The XML Data Source Object (DSO) is a Microsoft ActiveX control built into Microsoft Internet Explorer 4+. Using this object, it is possible to extract content from an external XML file or XML data embedded in the HTML file into a HTML page. In this article, I'll explain how to include the XML DSO, extract content from an external XML file, extract XML data from XML data embedded in the webpage and manipulation using JavaScript
XML Converter for MySQL database
by Rustem
MySQL has no native facilities for dealing with XML. This does not mean we are left out of the XML evolution. RustemSoft XML Converter has MySQL to XML support.
XML Ticker using XML Data Source Object (DSO)
by Premshree Pillai
This news ticker shows an example of data binding using the XML DSO which is an ActiveX control built into Microsoft Internet Explorer.
Creating An XML Newsfeed
by Jeff Anderson
A full explanation of how to take an XML newsfeed from moreover, amazon affiliates, google or any of the other current feed providers, and turn it into a display page using a little ASP.
XML Ticker
by Premshree Pillai
This is an XML based JavaScript Ticker that can tick any number of messages. The ticker works with IE only. The ticker reads it's contents, i.e the ticker style, text to be displayed, the link for that particular message from a XML file.
Amazon Lite Web Service
A complete XML web service allowing you to offer complete Amazon searches and disaply results on your site. A fantastic introduction to XML Web Services.
Batch processing XML with XSLT 2.0
by Krunal Patel
What you need is an XML version of the directory listing. Then, you could use that XML file as the single input file to XSLT and process each file using XSLT. It would be wonderful if you could do the directory processing in XSLT directly. Unfortunately, with all the power of XSLT -- and particularly XSLT 2.0 -- the language still doesn't have directory operations.

Recent Forum Threads
• Run a program both on windows and linux
• VERO.SurfCAM.v2014
• Schlumberger.Petrel.V2013.2
• Petrel.V2013.2
• Altair.HyperWorks.v12
• VoluMill.v6.1
• VoluMill.NEXION.6
• VERO.SurfCAM.v2014
• Schlumberger.Petrel.V2013.2

Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text

© Copyright 2001-2015