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/&g开发者_高级运维t;";
}
}
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);
?>
精彩评论