On this page
function _aggregator_parse_opml
_aggregator_parse_opml($opml)
Parses an OPML file.
Feeds are recognized as <outline> elements with the attributes "text" and "xmlurl" set.
Parameters
$opml: The complete contents of an OPML document.
Return value
An array of feeds, each an associative array with a "title" and a "url" element, or NULL if the OPML document failed to be parsed. An empty array will be returned if the document is valid but contains no feeds, as some OPML documents do.
File
- modules/aggregator/aggregator.admin.inc, line 383
- Administration page callbacks for the Aggregator module.
Code
function _aggregator_parse_opml($opml) {
$feeds = array();
$xml_parser = drupal_xml_parser_create($opml);
if (xml_parse_into_struct($xml_parser, $opml, $values)) {
foreach ($values as $entry) {
if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
$item = $entry['attributes'];
if (!empty($item['XMLURL']) && !empty($item['TEXT'])) {
$feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']);
}
}
}
}
xml_parser_free($xml_parser);
return $feeds;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!aggregator!aggregator.admin.inc/function/_aggregator_parse_opml/7.x