You are here

protected function FeedsCrawler::parseAuto in Feeds Crawler 7

Same name and namespace in other branches
  1. 6.2 FeedsCrawler.inc \FeedsCrawler::parseAuto()

Paginates using Atom's rel=next link automatically.

1 call to FeedsCrawler::parseAuto()
FeedsCrawler::fetch in ./FeedsCrawler.inc
Implements FeedsFetcher::fetch().

File

./FeedsCrawler.inc, line 71
Home of the FeedsCrawler.

Class

FeedsCrawler
Fetches data via HTTP.

Code

protected function parseAuto($result, $source_config) {
  $errors = $this
    ->errorStart();
  $xml = new SimpleXMLElement($result
    ->getRaw());
  feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
  $format = _parser_common_syndication_feed_format_detect($xml);
  if ($format) {
    $xml
      ->registerXpathNamespace('atom', 'http://www.w3.org/2005/Atom');
    $xpath = 'atom:link[@rel="next"]/@href';
  }
  else {
    $xpath = 'link[@rel="next"]/@href';
  }
  $href = $xml
    ->xpath($xpath);
  unset($xml);
  $this
    ->errorStop($errors, FALSE);
  return $this
    ->parseHref($href, $source_config['source']);
}