You are here

function common_syndication_parser_parse in Feeds 8.2

Same name and namespace in other branches
  1. 6 libraries/common_syndication_parser.inc \common_syndication_parser_parse()
  2. 7.2 libraries/common_syndication_parser.inc \common_syndication_parser_parse()
  3. 7 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()
CommonSyndicationParserTest::_testAtomGeoRSS in lib/Drupal/feeds/Tests/CommonSyndicationParserTest.php
Test Geo RSS in Atom feed.
CommonSyndicationParserTest::_testRSS10 in lib/Drupal/feeds/Tests/CommonSyndicationParserTest.php
Test RSS 1.0.
CommonSyndicationParserTest::_testRSS2 in lib/Drupal/feeds/Tests/CommonSyndicationParserTest.php
Test RSS 2.
FeedsSyndicationParser::parse in lib/Drupal/feeds/Plugin/feeds/parser/FeedsSyndicationParser.php
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) {
  @($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;
}