function aggregator_element_start

Performs an action when an opening tag is encountered.

Callback function used by xml_parse() within aggregator_parse_feed().

1 string reference to 'aggregator_element_start'
aggregator_parse_feed in drupal/modules/aggregator/aggregator.parser.inc
Parses a feed and stores its items.

File

drupal/modules/aggregator/aggregator.parser.inc, line 172
Parser functions for the aggregator module.

Code

function aggregator_element_start($parser, $name, $attributes) {
  global $item, $element, $tag, $items, $channel;
  $name = strtolower($name);
  switch ($name) {
    case 'image':
    case 'textinput':
    case 'summary':
    case 'tagline':
    case 'subtitle':
    case 'logo':
    case 'info':
      $element = $name;
      break;
    case 'id':
    case 'content':
      if ($element != 'item') {
        $element = $name;
      }
    case 'link':

      // According to RFC 4287, link elements in Atom feeds without a 'rel'
      // attribute should be interpreted as though the relation type is
      // "alternate".
      if (!empty($attributes['HREF']) && (empty($attributes['REL']) || $attributes['REL'] == 'alternate')) {
        if ($element == 'item') {
          $items[$item]['link'] = $attributes['HREF'];
        }
        else {
          $channel['link'] = $attributes['HREF'];
        }
      }
      break;
    case 'item':
      $element = $name;
      $item += 1;
      break;
    case 'entry':
      $element = 'item';
      $item += 1;
      break;
  }
  $tag = $name;
}