
|
2.05.2005 Hacking the Flickr RSS feed with ASP.NET to have photo-side blog... OK - like everybody else these days I got a new phone with lousy build-in vga camera. So time to create a Flickr account and start shooting. This was amazingly easy and really user-friendly made - took five minutes from signing up to the first picture was delievered by the phone - neat! Now I wanted - live everybody else these days - to have the latest flickr pictures posted on the right side of this blog. I still use blogger for whatever reason, so I would implement it using an Iframe with a ASP.NET page. Really easy using the Xml-control and the System.Net.WebRequest object. But what about parsing the RSS feed... Unfortunantly the Flickr RSS feed doesn't include a link to my picture alone - it only includes a description field with text and a link to the picture through an image-tag. Now time to start doing some two minutes nasty XSLT hacking: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="/rss/channel/item"> <xsl:if test="position() <= 2"> <p class="hartvigBody"> <a href="{link}" target="_blank"><img style="border: 1px solid #666" width="100" height="75" src="{concat(substring-before(substring-after(description, 'img src="'), '_m.'), '_t.jpg')}" alt="{concat(substring(substring-after(pubDate, ', '), 0, string-length(substring-after(pubDate, ', '))-14),': ', title)}"/></a><br/> <a href="{link}" target="_blank" class="smalllink"><xsl:value-of select="title"/></a><br/> </p> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> Not a beauty - but does the works. Especially the date hacking is nasty - if only I used umbraco with the nice date formatting xslt-helper methods ;-) Full files here if you want to implement it your self: photoblog.xslt webform1.aspx webform1.cs 0 Comment(s)...
Comments:
Post a Comment
Older stuff here... |
|
More banners here... To the weblog frontpage Email / Contact info umbraco - my company Call me through Skype Blog archive RSS Feed![]() commonme.org publicMIND urgent.dk asynkron Hr. Röser Interbreed OpenLife Loudthinking BlogBot.dk Tim O'Reilly - and his books steve mcconnel joel spolsky steve jobs bruce eckel ![]() |
|
|