Luciano Evaristo Guerche

A brazilian geek interested in .NET technologies

About Me

How to sort an OPML file

I once sent an email to Aaron Skonnard asking him for help on how to sort an OPML file, which is an XML file in fact, but received no reply so far. Maybe he is a busy person or maybe my question was too dumb to answer. Anyway, today I found out how to sort the OPML file I export through RSS Bandit. I enclosed below the XSLT sheet I created, just for appreciation. Any comment is welcome.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <opml version="1.0">
      <head/>
      <body>
        <xsl:for-each select="opml/body/outline">
          <xsl:sort select="@title"/>
          <outline title="{@title}">
            <xsl:for-each select="outline">
              <xsl:sort select="@title"/>
              <outline title="{@title}" xmlUrl="{@xmlUrl}"
               htmlUrl="{@htmlUrl}" description="{@description}"/>
            </xsl:for-each>
          </outline>
        </xsl:for-each>
      </body>
    </opml>
  </xsl:template>
</xsl:stylesheet>

My OPML file can be found at http://www.geocities.com/guercheLE/weblogs_asp_net/myfeeds.opml

Comments

Jon Galloway said:

Cool! That'll simplify something I've been wanting to do, which is OPML sync between work, desktop, and laptop OPML files. Looking forward to testing it out this weekend!
# June 4, 2004 5:41 PM

Luciano Evaristo Guerche said:

Jon,

Use, but pay attention my OPML file has only two level "outline". In case you have more than 2, you'll have to tweak it slightly.
# June 4, 2004 6:02 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)