Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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>
Comment | File | Size | Author |
---|---|---|---|
#2 | feeds_xpathparser-7.x-1.0-beta4-ContextValidationError.patch | 494 bytes | mikel1 |
Comments
Comment #1
mikel1 CreditAttribution: mikel1 commentedMore info - looks like it is using HTML parser even though 'plugin_key' => 'FeedsXPathParserXML',
from my research, 801 mean invalid HTML tag
Comment #2
mikel1 CreditAttribution: mikel1 commentedPoking 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.
Comment #3
Summit CreditAttribution: Summit commentedHi,
I think this is necessary, right? The previous operation should be cleaned?
greetings, Martijn
Comment #4
twistor CreditAttribution: twistor commentedCan you tell me where the errors are coming from?
Comment #5
mikel1 CreditAttribution: mikel1 commentedSee the original summary. Error occurs when saving settings for XPath XML parser.
Comment #7
twistor CreditAttribution: twistor commentedComment #8
twistor CreditAttribution: twistor commented