Jump to Sidebar Content | Jump to Main Page Content

Begin site navigation:
End site navigation.
Begin left menu:


End of left menu.
Begin main content:

Parsing OPML to Display Your Fargo Outline

Sunday, May 12, 2013 7:56 pm

I’ve been messing around with Fargo, the little outline tool from Dave Winer’s Small Pictures lab that you can use for notes and to-do lists. Though it does integrate with WordPress, I wanted to display a list in a standard PHP page. I discovered two ways to do this: 1) embed the Reader feed in an iframe or 2) parse the OPML file to display inline. Here’s how:

Embed the Reader feed in an iframe

1) Locate the Reader feed for your outline

  • From the Fargo menu, go to File > View in Reader

2) Copy the URL from the browser

3) Add the URL in an iframe, as this

<iframe src="http://reader.smallpicture.com/?opmlurl=https%3A%2F%2Fdl.dropbox.com%2Fs%2Fi08c5n3c0vqgczj%2FyardTasks.opml" width=70% height=500 frameBorder="0" scrolling="yes" allowtransparency="true"></iframe>

4) This will embed your outline as shown here:

Parse the OPML file to display inline

If you’d rather display the list inline without using an iframe, you need to convert the OPML file to HTML. Then you can format it as desired. Here’s a function using PHP’s SimpleXMLElement to output an OMPL file as a basic HTML list. For this example, I’m using an outline called “Yard Tasks”, you can view the OPML file here: https://dl.dropbox.com/s/i08c5n3c0vqgczj/yardTasks.opml

1) Locate the OPML feed for your outline

  • From the Fargo menu, go to File > Get Public Link
  • Create a public link for the “Yard Tasks” file? Click OK
  • Public link for “Yard Tasks”. Copy the URL, then click Ok

2) Add this code to your PHP file:

function parse_opml($xml,$depth=1) {
  if (count($xml->children()) > 0) {
foreach ($xml->children() as $child) {
  echo '<li>'.$child['text'].'</li>'; // level 1 outlines
  parse_opml($child,$depth+1); // nested outlines
  if (count($xml->children()) > 0) {
  echo '</ul>';
$file = new SimpleXMLElement("https://dl.dropbox.com/s/i08c5n3c0vqgczj/yardTasks.opml",null,true);
echo '<h4>' . $file->head->title . '</h4>';
echo '<em>' . 'Created in <a href="http://fargo.io/">Fargo</a> © 2013 <a href="http://smallpicture.com/">Small Picture<</a>, Inc.' . '</em>'; ?>

3) This will display your outline as shown here:

Yard Tasks

  • What to do with all the rocks?
  • Dispose of:
    • propane tank
    • canister
    • rusty mower
    • leftover paint
    • creepy old doghouse
    • pipe on north side
  • Dig up junipers:
  • Clean debris from planter off study patio

Created in Fargo © 2013 Small Picture, Inc.

4) You can pull other items from the OPML file, such as:

Creator = $file->head->ownerName
Email = $file->head->ownerEmail
File Date = $file->head->dateModified

5) Or display Fargo icons.

To do that, you will need to include the Font Awesome code in your website. Then add the icon class:

Change this line:

  echo '<li>'.$child['text'].'</li>'; // level 1 outlines

To this:

  echo '<li>'.' <i class="icon-'.$child['icon'].'"></i> '.$child['text'].'</li>'; // level 1 outlines

6) It will update when you save changes to your Fargo list - see the live example on my home page

7) Enjoy!


  1. The PHP implementation is very neatly done, I may have to use it on my website

    The only thing I think is missing is support for the attributes that I add to my OPML elements.

  2. Thanks Angelo! Haven’t worked with OPML before Fargo so my example is simple. You can pull the attributes out individually – for elements in <head> use the syntax in #4, for attributes in <outline> use $child[‘attribute’] (as in $child[‘type’] or $child[‘category’]). I’ll try to put those in an array though…

  3. Betsy,

    The post to fargo.io community feed that has a link to your wordpress has an issue.
    if one clicks on that highlighted link, it tries to open

    That gets a 404 error.

    I figured it out by reading the OPML. (I am *not* versed in OPML), but
    realized why I could not open your link.

    Not sure how or why this happened. it is possible to embed an external URL, I think I played with that at one time.

    p.s. I like your blog. I’m working on a book about a murder. It’s a long slog.

    Be well,


  4. Hi Ron, you may be thinking of Barbara? Her blog is here. Keep me posted on the book!

  5. I’m getting a whole bunch of parsing errors, don’t want to list them in the comments section, but they all start with Warning: SimpleXMLElement::__construct() and reference the line starting with $file =

  6. update: I subbed out the opml file with http://smallpicture.com/states.opml and it works — maybe there’s something about the opml file?

  7. Your file works as http://dl.dropboxusercontent.com/s/i08c5n3c0vqgczj/yardTasks.opml but not as what you have posted above. Maybe it’s a change in how Dropbox works. I apologize for commenting throughout my entire process, but glad this finally works for me.

  8. I just set this up on my wordpress blog: http://sasstrology.com/astrology-blogs-rss-feeds
    I added rss feed links with this adaptation:
    echo ‘ ‘.$child[‘text’].”;

  9. How did you get the nested hyperlink to work? Your php script doesn’t seem to accommodate that.

  10. Hi Jon, you are correct, it does not. Because it does not need to. Fargo outputs HTML entities in the OPML file, SimpleXMLElement spits out the text – it is the browser that renders the link.

  11. Yes, I see that Fargo outputs the text and url in OPML, but running your php script as it’s shown above, doesn’t pull in the URL field just the TEXT. Since writing this comment, I think I realized how to access the URL field in the $child, but I’d be interested in how you generated the tag selectively instead of the in the HTML list in your example.

End of main content.