Created
April 8, 2011 10:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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