Skip to content

Instantly share code, notes, and snippets.

@marcohamersma
Created April 8, 2011 10:26
Show Gist options
  • Save marcohamersma/909610 to your computer and use it in GitHub Desktop.
Save marcohamersma/909610 to your computer and use it in GitHub Desktop.
Very simple script for converting OPML files that are generated by OmniOutliner to HTML
<?
function parseOutliner($url) {
$content=file_get_contents($url);
$content=simplexml_load_string($content);
$title=$content->head->title;
$content=$content->body->outline;
foreach ($content as $item) {
$titleHTML=preg_replace('! <(http.*?)>!','<a class="ref" href="$1">@</a>',$item['text']);
$return.='<h2>'.$titleHTML.'</h2>';
foreach ($item->outline as $text) {
$return.= tx($text['text']);
if (isset($text->outline)) {
if (count($text->outline)>0) {
$return.= '<ul class="outlineList">';
foreach ($text->outline as $p) {
$return.= "<li>".tx($p['text'])."</li>";
}
$return.= "</ul>";
} else {
$return.= tx($text->outline['text']);
}
}
}
}
return array($return,$title);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment