You are here

protected static function FeedImport::processFeedNormal in Feed Import 7

Imports and process a feed normally

Parameters

array $feed: Feed info array

Return value

array An array of objects

File

./feed_import.inc.php, line 872
Feed import class for parsing and processing content

Class

FeedImport
@file Feed import class for parsing and processing content

Code

protected static function processFeedNormal(array $feed) {

  // Load xml file from url
  try {
    $xml = simplexml_load_file($feed['url'], self::$simpleXMLElement, LIBXML_NOCDATA);
  } catch (Exception $e) {
    return NULL;
  }

  // If there is no SimpleXMLElement object
  if (!$xml instanceof self::$simpleXMLElement) {
    return NULL;
  }

  // Get items from root
  $xml = $xml
    ->xpath($feed['xpath']['#root']);

  // Get total number of items
  $count_items = count($xml);

  // Check if there are items
  if (!$count_items) {
    return NULL;
  }

  // Check feed items
  foreach ($xml as &$item) {

    // Set this item value to entity, so all entities will be in $xml at end
    $item = self::createEntity($feed, $item);
  }
  unset($feed);

  // Return created entities
  return $xml;
}