请告诉我如何制作一个OPML解析器。我有代码,但它并不适用于所有通用的OPML文件:
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/>";
}
}发布于 2010-03-24 01:43:14
您可以使用PHP OPML解析器类,如下所示:http://www.mt-soft.com.ar/2007/12/21/opml-parser-php-class/
示例用法:
<?php
$url = 'http://example.com/foo.opml'; // URL of OPML file
$parser = new IAM_OPML_Parser();
echo $parser->displayOPMLContents($url);
?>https://stackoverflow.com/questions/2502231
复制相似问题