Kirk Evans Blog

.NET From a Markup Perspective

Organize Your OPML

Organize Your OPML

  • Comments 4

I really like the ability to organize the subscriptions I have within SharpReader and RSSBandit.  However, the tree view metaphor makes organization cumbersome, espeically if you come up with a reorganization scheme.  I decided to group my subscriptions by their associated entity (ie., DevelopMentor, Microsoft, DotNetWebLogs, Kuro5hin, Radio), which would get me 90% of the way that I needed to go, organizationally.  I know of the few others that don't fit (like Joshua Allen, whose URL "SimpleGeek" does not fit within the "gotdotnet.com" match type), but overall this approach works for me.  Thought it might work for someone else as well.

<xsl:stylesheet version ="1.0" xmnlns:xsl ="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match ="/" >
<opml>
<body>
<outline title ="MSDN" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'msdn.microsoft.com') or contains(@htmlUrl,'microsoft.com')]" >
<xsl:sort select ="@title" />
</xsl:apply-templates>
</outline>
<outline title ="Microsoft" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'gotdotnet')]" >
<xsl:sort select ="@title" />
</xsl:apply-templates>
</outline>
<outline title ="DevelopMentor" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'develop.com')]" >
<xsl:sort select ="@title" />
</xsl:apply-templates>
</outline>
<outline title ="DotNetWebLogs" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'dotnetweblogs.com')]" />
</outline>
<outline title ="kuro5hin" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'kuro5hin.org')]" />
</outline>
<outline title ="Radio" >
<xsl:apply-templates select ="opml/body/descendant::outline[contains(@xmlUrl,'userland.com') or contains(@xmlUrl,'radio.weblogs.com')]" >
<xsl:sort select ="@title" />
</xsl:apply-templates>
</outline>
<outline title ="General" >
<xsl:apply-templates select ="opml/body/descendant::outline[@xmlUrl and not(contains(@xmlUrl,'develop.com') or contains(@xmlUrl,'gotdotnet') or contains(@xmlUrl,'dotnetweblogs.com') or contains(@xmlUrl,'msdn.microsoft.com') or contains(@xmlUrl,'userland.com') or contains(@htmlUrl,'microsoft.com') or contains(@xmlUrl,'kuro5hin.org') or contains(@xmlUrl,'radio.weblogs.com'))]" >
<xsl:sort select ="@title" />
</xsl:apply-templates>
</outline>
</body>
</opml>
</xsl:template>
<xsl:template match ="outline" >
<xsl:element name ="outline" >
<xsl:apply-templates select ="@*" />
</xsl:element>
</xsl:template>
<xsl:template match ="@*" >
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>

 

 

  • Ummm, isn't SimpleGeek Chris Anderson's domain name while Joshua is NetCrucible?
  • Errr... yeah... my brain fart.
  • So how do I use this snippet exactly?
  • The easiest way to use it is to save the OPML and the XSLT to separate files on your harddrive. Use something like the following code:

    using System;
    using System.Xml;
    using System.Xml.Xsl;

    namespace OPMLOrg
    {
    class Class1
    {
    static void Main(string[] args)
    {
    XslTransform trans = new XslTransform();
    trans.Load(@"c:\projects\trans.xslt",new XmlUrlResolver());
    trans.Transform(@"c:\projects\opml.xml",@"c:\projects\newopml.xml",new XmlUrlResolver());
    }
    }
    }
Page 1 of 1 (4 items)
Leave a Comment
  • Please add 2 and 1 and type the answer here:
  • Post
Translate This Page
Search
Archive
Archives