Editing a feed that has been working on my site for months. When I tried to edit the settings for XPath XML parser, it would not save the changes. It complains about the Context, which is "//videos/video". In fact, I can't get it to accept any selector at all for Context, including examples from the XPath parser documentation. Exported importer is as follows:

$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'experimental_video_importer';
$feeds_importer->config = array(
  'name' => 'experimental video importer',
  'description' => '',
  'fetcher' => array(
    'plugin_key' => 'FeedsFileFetcher',
    'config' => array(
      'allowed_extensions' => 'txt csv tsv xml opml html htm',
      'direct' => 1,
      'directory' => 'public://feeds',
      'allowed_schemes' => array(
        0 => 'public',
      ),
    ),
  ),
  'parser' => array(
    'plugin_key' => 'FeedsXPathParserXML',
    'config' => array(
      'sources' => array(
        'xpathparser:0' => 'caption',
        'xpathparser:2' => 'id',
        'xpathparser:4' => 'gpslatitude',
        'xpathparser:5' => 'gpslongitude',
        'xpathparser:6' => 'useremail',
        'xpathparser:7' => 'url',
        'xpathparser:8' => 'id',
        'xpathparser:9' => 'path',
      ),
      'rawXML' => array(
        'xpathparser:0' => 0,
        'xpathparser:2' => 0,
        'xpathparser:4' => 0,
        'xpathparser:5' => 0,
        'xpathparser:6' => 0,
        'xpathparser:7' => 0,
        'xpathparser:8' => 0,
        'xpathparser:9' => 0,
      ),
      'context' => '//videos/video',
      'exp' => array(
        'errors' => 1,
        'debug' => array(
          'context' => 'context',
          'xpathparser:0' => 'xpathparser:0',
          'xpathparser:2' => 'xpathparser:2',
          'xpathparser:4' => 'xpathparser:4',
          'xpathparser:5' => 'xpathparser:5',
          'xpathparser:6' => 'xpathparser:6',
          'xpathparser:7' => 'xpathparser:7',
          'xpathparser:8' => 'xpathparser:8',
          'xpathparser:9' => 'xpathparser:9',
        ),
      ),
      'allow_override' => 0,
    ),
  ),
  'processor' => array(
    'plugin_key' => 'FeedsNodeProcessor',
    'config' => array(
      'expire' => '-1',
      'author' => 0,
      'authorize' => 1,
      'mappings' => array(
        0 => array(
          'source' => 'xpathparser:0',
          'target' => 'title',
          'unique' => FALSE,
        ),
        1 => array(
          'source' => 'xpathparser:2',
          'target' => 'guid',
          'unique' => 1,
        ),
        2 => array(
          'source' => 'xpathparser:4',
          'target' => 'field_location:locpick][user_latitude',
          'unique' => FALSE,
        ),
        3 => array(
          'source' => 'xpathparser:5',
          'target' => 'field_location:locpick][user_longitude',
          'unique' => FALSE,
        ),
        4 => array(
          'source' => 'xpathparser:6',
          'target' => 'user_mail',
          'unique' => FALSE,
        ),
        5 => array(
          'source' => 'xpathparser:7',
          'target' => 'path_alias',
          'unique' => FALSE,
        ),
        6 => array(
          'source' => 'xpathparser:8',
          'target' => 'field_staging_id',
          'unique' => FALSE,
        ),
        7 => array(
          'source' => 'xpathparser:9',
          'target' => 'field_video_file',
          'unique' => FALSE,
        ),
      ),
      'update_existing' => '0',
      'input_format' => 'plain_text',
      'skip_hash_check' => 0,
      'bundle' => 'video',
    ),
  ),
  'content_type' => 'video_feed',
  'update' => 0,
  'import_period' => '-1',
  'expire_period' => 3600,
  'import_on_create' => 0,
  'process_in_background' => 0,
);

Feed data looks like this:

<?xml version="1.0"?>
<videos>
<video>
<id>1234</id>
<caption>My Video</caption>
<gpslatitude>40</gpslatitude>
<gpslongitude>-78</gpslongitude>
<path>public://media/myvideo.mov</path>
<useremail>myemail@google.com</useremail>
</video>
</videos>
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikel1’s picture

More info - looks like it is using HTML parser even though 'plugin_key' => 'FeedsXPathParserXML',

$error = LibXMLError Object
(
    [level] => 2
    [code] => 801
    [column] => 442
    [message] => Tag source invalid

    [file] => 
    [line] => 2
)
'

from my research, 801 mean invalid HTML tag

mikel1’s picture

Poking around a little more, the error is set form some previous operation - it has nothing to do with the current operation, but it has not been cleared. Clearing the errors right after constructing the XML element but before testing if Context is valid fixes the problem. Patch is attached.

Summit’s picture

Status: Active » Needs review

Hi,
I think this is necessary, right? The previous operation should be cleaned?

greetings, Martijn

twistor’s picture

Can you tell me where the errors are coming from?

mikel1’s picture

See the original summary. Error occurs when saving settings for XPath XML parser.

  • twistor committed cc14e52 on 7.x-1.x
    Issue #1997768 by mikel1: Fixed Will not accept Context.
    
twistor’s picture

Status: Needs review » Fixed
twistor’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev

  • twistor committed f6f1365 on
    Issue #1997768 by mikel1: Fixed Will not accept Context.
    

  • twistor committed 4e1540b on
    Issue #1997768 by mikel1: Fixed Will not accept Context.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.