Ask Leo! by Leo A. Notenboom

How can I list blog entries on my non-blog web page?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » Web » Web Site Management

Summary: You often see recent blog entries listed on web pages. If those pages weren't generated by the original blogging software, it's a little tricky to do.

How can I list blog entries on my non-blog web page?

The short answer is that I'm afraid it's not just some simple HTML. It will take some server-side code to do it. The good news is that since most blogging software now automatically provides an RSS feed in one form or another, that feed is a great source for what you want to display. The additional code on your server transforms that feed into HTML that works on your site and then you display the results.

If your pages are already being generated by something dynamic like PHP or ASP, then the best way to accomplish what you want is to add the transformation code to the desired page directly. As one example I've included an VBScript function below, displayRSS, that I've used in ASP pages. It takes pointers to an RSS Feed and an XSLT transformation applies the transformation and returns the results for display. XSLT is a programming language highly optimized for transforming structured XML data, which is what an RSS feed is, into other forms such as HTML. A simple transformation can return all or portions of the information contained within the feed.

If your pages are static you're not sunk as long as you have access to some form of CGI to run server-side code. I've created an example Perl script, grabrss.pl, that runs as a CGI that will transform an RSS feed into an HTML bullet list. As an alternative to using XSLT, grabrss uses only an XML parser and pulls apart the component fields we might care about and pushes out the HTML as a series of jscript "document.writeln" statements. In your static HTML page just include:

<script language="jscript" src="http://yourserver/cgibin/grabrss.pl"> </script>

This will include the script and execute it in place resulting in the HTML bullet list being displayed. As I said, grabrss is an example. I'm sure not everyone wants a bullet list, but it should be easy to modify to output the HTML specifics that you want.

You can get a copy of grabrss.pl here.

DisplayRSS, the ASP sample, follows here:

Function displayRSS(ByVal strSource, ByVal strXSL)
    Dim xmlHTTP, xmlRSSSource, xmlStyle
    Dim strXSLFile

    ' Use the XMLHTTPConnection object to grab the feed
    Set xmlHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    xmlHTTP.Open "GET", strSource, False
    xmlHTTP.Send

    ' Load the feed into a DOM object
    Set xmlRSSSource = Server.CreateObject("Microsoft.XMLDOM")
    xmlRSSSource.async = False
    xmlRSSSource.loadXML(xmlHTTP.ResponseText)

    ' Load the XSL style sheet
    strXSLFile = Server.MapPath(strXSL)
    Set xmlStyle = Server.CreateObject("Microsoft.XMLDOM")
    xmlStyle.async = False
    xmlStyle.load(strXSLFile)

    ' Render the feed using the style sheet
    displayRSS = xmlRSSSource.transformNode(xmlStyle)

    ' Release resources
    Set xmlStyle = Nothing
    Set xmlRSSSource = Nothing
    Set xmlHTTP = Nothing
End Function

Article C1844 - September 26, 2003

Helpful? Get new articles weekly by email in my FREE newsletter!

Your Name:
Your Email:


Why Subscribe?

Recent Comments
5 Comments

Thank you for good code. i'am completely agree with author that "it's not just some simple HTML". Use this code take a lot of time from me.

Posted by: erik@turnek.com at May 6, 2004 5:18 PM

This is a wonderful tiny script. I am using modified version of this script to grab my LJ entries on my home page. The page is not online now but will be in a day or two. -- Thank you very much for providing this

-Pankaj
http://jangid.freeshell.org/

Posted by: Pankaj Jangid at October 8, 2005 9:16 PM

LEO How can I start a softball blog? Blog novice here. elo

Posted by: ELO at October 18, 2005 9:53 AM

I'd start with one of the services like TypePad.com or blogger.com

Posted by: Leo at October 18, 2005 2:10 PM

i am using open source library MagpieRSS to show my blog post on my web page.

http://www.aknamdeo.com/wordpress/?p=17

Posted by: Ashish at February 25, 2006 2:22 AM

Post a comment on "How can I list blog entries on my non-blog web page?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

  • Read the article at the top of this page. If your comment shows you didn't, it'll be deleted and ignored.

  • Comment only on this article. Use the Google search box at the top of the page if you have a question about something else.

  • Don't include personal information in the comment. No email addresses. No phone numbers. No physical addresses.

  • Don't spam. Excessive links to unrelated sites within a comment or across multiple comments will cause all such comments to be removed.

  • Don't ask me to recover lost passwords or hacked accounts. I can't, and those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...


Question? Ask Leo!