Recently I needed to extract all xmlURL attributes from an OPML file for command line processing. (Specifically I needed a way to pipe them to the excellent rss2email.)

Enclosed herewith go some instructions for how to do this for the technically inclined.

Because OPML is some XML flavour it only seemed natural to use XSLT for doing the data crunching (what an ellaborate name for what I actually did). The same goal could have probably been achieved with a bit of P-language scripting magic, but I'm still learning this whole XSLT thing and so I took the chance for some "learning by doing".

  1. Get the OPML file. In my case this involved clicking my way through Bloglines. Save it as something like input.opml.
  2. Get the XSLT script. You can either click the link or copy & paste it from below:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="">
      <xsl:output method="text" />
      <xsl:template match="/">
        <xsl:for-each select="//@xmlUrl">
          <xsl:value-of select="." />
          <xsl:text>&#xA;</xsl:text> <!-- force a line break after each URL -->
  3. Call the XSLT processor and pipe its output to the desired command:
    xsltproc opml2text.xsl input.opml | r2e add
  4. That's it.
Written on 2005-10-19 21:18:11.