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="https://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="https://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">
<a href="<xsl:value-of select="link"/>"><xsl:value-of select="title"/></a>
</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,"&","&") && convert "&" to "&"
cTrans=STRTRAN(cTrans,">",">")
cTrans=STRTRAN(cTrans,"<","<")
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