You are here

function common_syndication_parser_parse in Feeds 7

Same name and namespace in other branches
  1. 8.2 libraries/common_syndication_parser.inc \common_syndication_parser_parse()
  2. 6 libraries/common_syndication_parser.inc \common_syndication_parser_parse()
  3. 7.2 libraries/common_syndication_parser.inc \common_syndication_parser_parse()

Parse the feed into a data structure.

Parameters

$feed: The feed object (contains the URL or the parsed XML structure.

Return value

stdClass The structured datas extracted from the feed.

4 calls to common_syndication_parser_parse()
CommonSyndicationParserTestCase::_testAtomGeoRSS in tests/common_syndication_parser.test
Test Geo RSS in Atom feed.
CommonSyndicationParserTestCase::_testRSS10 in tests/common_syndication_parser.test
Test RSS 1.0.
CommonSyndicationParserTestCase::_testRSS2 in tests/common_syndication_parser.test
Test RSS 2.
FeedsSyndicationParser::parse in plugins/FeedsSyndicationParser.inc
Implements FeedsParser::parse().

File

libraries/common_syndication_parser.inc, line 21
Downloading and parsing functions for Common Syndication Parser. Pillaged from FeedAPI common syndication parser.

Code

function common_syndication_parser_parse($string) {
  if (!defined('LIBXML_VERSION') || version_compare(phpversion(), '5.1.0', '<')) {
    @($xml = simplexml_load_string($string, NULL));
  }
  else {
    @($xml = simplexml_load_string($string, NULL, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA));
  }

  // Got a malformed XML.
  if ($xml === FALSE || is_null($xml)) {
    return FALSE;
  }
  $feed_type = _parser_common_syndication_feed_format_detect($xml);
  if ($feed_type == "atom1.0") {
    return _parser_common_syndication_atom10_parse($xml);
  }
  if ($feed_type == "RSS2.0" || $feed_type == "RSS0.91" || $feed_type == "RSS0.92") {
    return _parser_common_syndication_RSS20_parse($xml);
  }
  if ($feed_type == "RDF") {
    return _parser_common_syndication_RDF10_parse($xml);
  }
  return FALSE;
}