Manzoor Husain
Manzoor Husain

Reputation: 11

PHP OPML Parser

Kindly tell me how to make an OPML parser. I have the code but it is not working for all generic OPML files:

if (file_exists('test.opml')) {
    $xml =simplexml_load_file('test.opml');
}

for($i=0;$i<=count($xml);$i++) {
    $array=array($xml->body->outline->outline[$i]);
    $key=(array_keys($array));
    foreach ($array as $key) {
        echo "<strong>".($key['xmlUrl'][0])."</strong><br/>";
    }
}

Upvotes: 1

Views: 2631

Answers (1)

Mathias Bynens
Mathias Bynens

Reputation: 149704

You could use a PHP OPML parser class, like this one: http://www.mt-soft.com.ar/2007/12/21/opml-parser-php-class/

Sample usage:

<?php
$url = 'http://example.com/foo.opml'; // URL of OPML file
$parser = new IAM_OPML_Parser();
echo $parser->displayOPMLContents($url);
?>

Upvotes: 0

Related Questions