You are here

function _parser_common_syndication_feed_format_detect in Feeds 7.2

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

Determine the feed format of a SimpleXML parsed object structure.

Parameters

SimpleXMLElement $xml: SimpleXML-preprocessed feed.

Return value

string|false The feed format short description or FALSE if not compatible.

1 call to _parser_common_syndication_feed_format_detect()
common_syndication_parser_parse in libraries/common_syndication_parser.inc
Parse the feed into a data structure.

File

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

Code

function _parser_common_syndication_feed_format_detect($xml) {
  if (!is_object($xml)) {
    return FALSE;
  }
  $attr = $xml
    ->attributes();
  $type = strtolower($xml
    ->getName());
  if (isset($xml->entry) && $type == "feed") {
    return "atom1.0";
  }
  if ($type == "rss" && $attr["version"] == "2.0") {
    return "RSS2.0";
  }
  if ($type == "rdf" && isset($xml->channel)) {
    return "RDF";
  }
  if ($type == "rss" && $attr["version"] == "0.91") {
    return "RSS0.91";
  }
  if ($type == "rss" && $attr["version"] == "0.92") {
    return "RSS0.92";
  }
  return FALSE;
}