Read OPML File

Whipped out this little script to read an OPML file from Google Reader. Thought it may be handy.

<cfset GoogleOPMLFile = "C:/google-reader-subscriptions.xml" />
<cffile action="READ" variable="xml" file="#GoogleOPMLFile#" /> 
<cfset xmlDoc = XMLParse(xml) /> 
<cfset StartingDataNode = 2 />
<cfset Categories = ArrayLen( xmlDoc.opml.xmlChildren[2].XmlChildren ) />
<cfloop index="i" from="2" to="#Categories#">
  <cfloop index="j" from="1" to="#ArrayLen( xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren )#">      	    
      <a href="#xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren[j].XmlAttributes.htmlURL#">

The code will display as follows:

Handy Free XML Tools

Here are two handy apps I use when I have to parse XML data.

firstobject XML Editor – This is a great tool that I primary use for formating XML into a more readable format. I just paste it in the editor, hit F8, and it beautifies it. It does more than that, but that’s what I use it the most.


Buba XPath builder – This is a nice tool where you can create an XPath search string and it shows you the results in real time by applying it to your XML data.