Welcome to MSDN Blogs Sign in | Join | Help

Use a simple XSLT to read the RSS feed from a blog

On most Blogs, there is a link called “Syndication”,”RSS”, or “XML” that is the RSS feed. Click on that, and you see an XML document that contains some recent blog posts.

 

This simple code reads the RSS feed for my blog, does an XSLT transform of the XML to a simple HTML file, and opens the HTML in IE

 

Just start VFP, choose File->New->Program, paste in this code, then hit Ctrl-E to run it.

 

cUrl="http://blogs.msdn.com/calvin_hsia/Rss.aspx"

oHTTP=CREATEOBJECT("winhttp.winhttprequest.5")

oHTTP.Open("POST",cUrl,.f.)

oHTTP.Send()

*ohttp.SetTimeouts( && use this for setting the timeouts

 

TEXT TO cXSLT noshow

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="html"/>

<xsl:template match="/">

<HTML>

<body>

<title>

<xsl:value-of select="//rss/channel/title"/>

</title>

<xsl:for-each select="//rss/channel/item">

<font color="#ff00ff" size="4">

&lt;a href="<xsl:value-of select="link"/>"&gt;<xsl:value-of select="title"/>&lt;/a&gt;

</font>

<p><xsl:value-of select="pubDate"/></p>

<p>

<xsl:value-of select="description"/>

</p>

<br/>

</xsl:for-each>

 

</body>

</HTML>

</xsl:template>

</xsl:stylesheet>

ENDTEXT

 

oXML=CREATEOBJECT("msxml.domdocument")

oXML.loadXML(oHTTP.ResponseText)

oXSLT=CREATEOBJECT("msxml.domdocument")

oXSLT.loadXML(cXSLT)

cTrans=oxml.transformNode(oxslt)    && do the XSLT transform

cTrans=STRTRAN(cTrans,"&amp;","&")  && convert "&amp;" to "&"

cTrans=STRTRAN(cTrans,"&gt;",">")

cTrans=STRTRAN(cTrans,"&lt;","<")

 

STRTOFILE(cTrans,"c:\t.htm")        && output to a tempfile

oie=CREATEOBJECT("internetexplorer.application")

oie.visible=1

oie.navigate("c:\t.htm")

 

 

My next post will show how to retrieve all posts from a particular blog.

 

47844

 

Published Tuesday, January 11, 2005 1:05 PM by Calvin_Hsia

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Use a simple XSLT to read the RSS feed from a blog

Tuesday, January 11, 2005 5:57 PM by Yavuz Bogazci's Blog

# re: Use a simple XSLT to read the RSS feed from a blog

Tuesday, January 11, 2005 3:52 PM by Mr Blobby
Or, just use Opera/Firefox/Maxthon/Deepnet/whatever?

# Do you like reading a blog author? Retrieve all blog entries locally for reading/searching using XML, XSLT, XPATH

Wednesday, January 12, 2005 4:36 PM by Calvin Hsia's WebLog

# Do you like reading a blog author? Retrieve all blog entries locally for reading/searching using XML, XSLT, XPATH

Wednesday, January 12, 2005 4:41 PM by Calvin Hsia's WebLog

# Transform RSS feed to HTML using XSLT

Tuesday, January 18, 2005 3:21 AM by .Net Adventures

# Generating VBScript to read a blog

Friday, August 05, 2005 2:25 PM by Calvin Hsia's WebLog
Sometimes I need to test something using VBScript. A user sends a code snippet and asks why it behaves...

# Webcrawl a blog to retrieve all entries locally: RSS on steroids

Thursday, May 25, 2006 8:32 PM by Calvin Hsia's WebLog
Today’s sample shows how to create a web crawler in the background. This crawler starts with a web page,...

# Poshol naxui

Friday, May 11, 2007 3:24 PM by pwisg

http://Booksa.vdforum.ru <a href= http://Booksa.vdforum.ru >Out of print books</a> [url=http://Booksa.vdforum.ru]Out of print books[/url]

# Use new XML Features of VB to generate dynamic scripts and text files

Thursday, October 04, 2007 1:53 PM by Calvin Hsia's WebLog

There's a very useful feature that FoxPro users have had for over 2 decades: being able to output text

# Use new XML Features of VB to generate dynamic scripts and text files

Thursday, October 04, 2007 1:58 PM by Noticias externas

There&#39;s a very useful feature that FoxPro users have had for over 2 decades: being able to output

# MSDN Blog Postings &raquo; How to Create dynamic XAML to display arbitrary XML

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker