Free Download:
|
| |
| iwonder | Asp.Net User |
| Re: Editing format of "pubDate" in News Feed RSS | 9/9/2005 7:31:03 PM |
1/1 | |
|
Welcome to the project. I started looking at RSS a while back, and found loads of examples of xsl stylesheets, though it was more than a frustrating experience. Now, for your problem at hand, yes, I'd start with modifying the existing xsl included, although, I'd recommend creating a new version and saving it, giving it a descriptive name. Something like - rssJustpubDate.xsl. Then, take your newsfeed module and use the new xsl to transform it. For example, the default xsl does not include the pubDate element, because it is NOT part of the RSSv0.91 spec, so all you need to do is take out the pieces you don't want and put in the ones you want. Of course, you must have a newsfeed that includes the pubDate, too!
Default DNN91.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:param name="TITLE"/><xsl:template match="rss"> <!-- Do not show channel image --> <xsl:for-each select="channel/item"> <br> <strong><a href="{link}" target="_main"><xsl:value-of select="title"/></a></strong><br></br> <!-- only display markup for description if it's present --> <xsl:value-of select="description"/> </br> <br></br> </xsl:for-each> </xsl:template> <xsl:template match="description"> <br> <xsl:value-of select="."/> </br> </xsl:template> </xsl:stylesheet>
Modified rssJustpubDate.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:param name="TITLE"/> <xsl:template match="rss"> <xsl:for-each select="channel/item"> <div> <strong><a href="{link}" target="_main"><xsl:value-of select="title"/></a></strong><br/> <xsl:value-of select="pubDate"/> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet>
I used the above stylesheet with a Newsfeed module, using the RSS from these forums as a source. It renders the Title (link) and the pubdate on the next line. This should give you a place to start...
News Feeds (RSS) |
|
|
|
iwonder Mission, KS - USA |
| iwonder | Asp.Net User |
| Re: Editing format of "pubDate" in News Feed RSS | 9/10/2005 12:38:09 AM |
0/0 | |
|
Ok, now that you've seen an example of how to display the elements you want, Title, and pubDate, how can you change the format of the pubDate to show only the date? That's where learning more about xsl comes in to play. There's no substitute for learning about specific functions from any one of the fine XML resources, you can uncover with a google search. However, I'll show you 1 way to do it, and leave the rest for you to explore.
Here's a source RSS newsfeed:
<?xml version="1.0" encoding="iso-8859-1"?> <rss version="0.91"> <channel> <title>HandCoded News</title> <link>http://www.hgworks.com/DesktopDefault.aspx?tabid=25</link> <description>HGWorks ...bringing the vision into focus. Link for more info.</description> <language>en-us</language> <copyright>Copyright 2003-2004 HGWorks / Handcoded</copyright> <managingEditor>[email protected]</managingEditor> <webMaster>[email protected]</webMaster> <pubDate>Sat, 12 Mar 2005 20:21 GMT</pubDate> <lastBuildDate>Sat, 12 Mar 2005 20:21 GMT</lastBuildDate> <image> <title>Our Support Team</title> <url>http://www.hgworks.com/images/xml.gif</url> <link>http://hgworks.com/Portals/6b6e1a80-f39d-4ee0-b692-2d81ed9cfb26/hghcNews.xml</link> <width>32</width> <height>14</height> <description>Subscribe to our news feed by clicking this link button. Copy the URL and insert into your favorite news feed reader. (© 2004 - www.hgworks.com/handcoded)</description> </image> <item> <title>Nukeleus - DNN Installer Beta</title> <pubDate>Sat, 12 Mar 2005 20:21 GMT</pubDate> <link>http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=853647</link> <description>Check out this utility for installing DNN. It's in beta, but it's going to make a lot of folks happy... </description> </item> <item> <title>DotNetNuke v3.x Released</title> <pubDate>Sat, 12 Mar 2005 20:21 GMT</pubDate> <link>http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=855467</link> <description>DNNv3.x released. Check the official announcement for details... </description> </item> </channel> </rss>
And a sample xsl that transforms the feed using an xsl function to extract just the date portion of the item element's pubDate. Just a matter of using the substring function, which is handy for limiting the number of characters to display for any string. I mostly use it to limit the number of characters in a description element when I need to do that chore. However, it works pretty cool for this solution, too.
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:param name="TITLE"/> <xsl:template match="rss"> <xsl:for-each select="channel/item"> <div> <strong><a href="{link}" target="_main"><xsl:value-of select="title"/></a></strong><br/> <xsl:value-of select="substring(pubDate,1,16)"/> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet>
The output looks like this:
Nukeleus - DNN Installer Beta Sat, 12 Mar 2005
DotNetNuke v3.x ReleasedSat, 12 Mar 2005 The key to using xsl to transform newsfeeds is to inpect and understand the newsfeed source, then you can do most anything you want with it, transformation-wise that is. :) One other tip to help you learn more about xml and xsl is to invest in a good xml editor, which will save you countless hours of frustration, because you can actually test and see what your code will look like against a source xml file, which is what RSS newsfeeds are anyway.
iwonder Mission, KS - USA |
| iwonder | Asp.Net User |
| Re: Editing format of "pubDate" in News Feed RSS | 9/13/2005 3:02:03 PM |
0/0 | |
|
Yes, that's a great link for info. The functions should be useful, but the main thing is to test - test - test. Browser implementation of xml support varies, and I find testing the xsl very beneficial. Now, I illustrated methods from the standpoint of transforming the xml/rss feed element for pubDate, but there are ways to affect the actual creation of the rss feed, which is a core function. I generally do not advocate making changes to Core functions, unless you absolutely have to do it, and then, you have to really be careful to plan the change, and keep track of the changes, so the next upgrade doesn't blow your work and site away
iwonder Mission, KS - USA |
|
| |
Free Download:
|
Books: Syndicating Web Sites with RSS Feeds For Dummies Authors: Ellen Finkelstein, Chris Pirillo, Pages: 350, Published: 2005 Developing Feeds with RSS and Atom: [developer's guide to syndicating news and blogs] Authors: Ben Hammersley, Pages: 253, Published: 2005 Windows Vista Sidebar: Your Visual Blueprint for Developing Cool Gadgets for the Windows OS Authors: Dave Konopka, Pages: 320, Published: 2007 Professional SQL Server 2005 Integration Services Authors: Brian Knight, Allan Mitchell, Darren Green, Douglas Hinson, Kathi Kellenberger, Andy Leonard, Erik Veerman, Jason Gerard, Haidong Ji, Mike Murphy, Pages: 692, Published: 2006 Building Flickr Applications with PHP Authors: Rob Kunkle, Andrew Morton, Pages: 194, Published: 2006 The Internet: The Missing Manual Authors: David Pogue, J. D. Biersdorfer, Pages: 442, Published: 2006 RSS And Atom: Understanding And Implementing Content Feeds And Syndication Authors: Heinz Wittenbrink, Pages: 250, Published: 2005 Professional Web APIs with PHP: EBay, Google, PayPal, Amazon, FedEx, Plus Web Feeds Authors: Paul Michael Reinheimer, Pages: 356, Published: 2006 Essential Blogging: Selecting and Using Weblog Tools Authors: Cory Doctorow, Shelley Powers, Rael Dornfest, J. Scott Johnson, Benjamin Trott, Mena G. Trott, Pages: 244, Published: 2002 Beginning Expression Web Authors: Zak Ruvalcaba, Pages: 474, Published: 2007 Web:RSS 2.0 Specification (RSS 2.0 at Harvard Law) This enables aggregators to not repeat items, even if there have been editing changes. If you have questions about the RSS 2.0 format, please post them on ... RSS - Wikipedia, the free encyclopedia RSS 1.0 is an RDF format like RSS 0.90, but not fully compatible with it, ... [ edit] RSS 1.0. The following is an example of an RSS Feed 1.0 file (the ... DotNetNuke: Setting up the RSS News Feed XSL Stylesheet,Tutorial In the module settings of the RSS News Feed Module, select Edit News Feed ... ( Replace "pubDate" with the TAG element you wish to display from the RSS feed) ... RSS Feeds - Webcontent.gov - Guide to Managing U.S. Government ... How to use RSS feeds to deliver current news about your agency, and see what ... The only thing of specific note is the format for the element. ... HOWTO: Create An RSS New Feed For Your Power Tab Related Web Site This article demonstrates how to create an RSS news feed for your Web site ... for your own feed, but ultimately the content and format is left up to you. ... Basic Guide to Creating an Rss News Feed tells when your news feed was born (or re-born). The way the date is displayed is special, and the format must be followed down to the last comma ... University Web Guide | Using RSS News Feeds on your website. Once everything in the inital setup is working you can edit the RSS file, ... link element or a valid date format in the PubDate element such as: Thursday, ... Can I remove the time from pubDate? He meant that you cannot get rid of "pubDate: from your RSS feed, which I've come to realize that you aren't, you just want to format the ... Low End Mac: Value Creating an RSS News Feed with PHP and MySQL An RSS (Rich Site Summary) news feed is a text file that others can use to find out what's new on your website. There's a standard format for these ... question re: date format in RSS news feeds Talk about question re: date format in RSS news feeds. ... converting the date format of "pubDate" into a datetime variable: ...
|
|
Search This Site:
|
|