Skip to content
Snippets Groups Projects
Commit 54d482ca authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Changed from using the XPath | (and) operator to running the queries...

Changed from using the XPath | (and) operator to running the queries individually. Gives results as expected.
parent f6b42f9c
No related branches found
No related tags found
Loading
......@@ -61,31 +61,36 @@ class FeedsXPathParser extends FeedsParser {
}
}
$final_query = implode(' | ', $queries);
$results = @$xml->xpath($final_query);
unset($xml);
if (!$results) {
drupal_set_message(t('There was an error with one of your XPath queries.
Make sure the syntax is valid.'), 'error');
return;
$results = array();
foreach ($queries as $key => $query) {
$result = @$xml->xpath($query);
if (!$result) {
drupal_set_message(t('There was an error with one of your XPath queries.
Make sure the syntax is valid.'), 'error');
return;
}
$results[$sources[$key]] = $result;
}
unset($xml);
$num_sources = count($sources);
$output = array_chunk($results, $num_sources);
foreach ($output as $key => $items) {
if ($num_sources == count($items)) {
foreach ($items as $k => $item) {
if (in_array($sources[$k], $rawXML)) {
$items[$k] = $item->asXML();
$output = array();
foreach ($results as $source => $items) {
if (!isset($count) || $count == count($items)) {
foreach ($items as $key => $item) {
if (in_array($source, $rawXML)) {
$item = $item->asXML();
}
else {
$item = (string) $item;
}
if (isset($output[$key])) {
$output[$key] = array_merge(array($source => $item), $output[$key]);
}
else {
$items[$k] = (string) $item;
$output[$key] = array($source => $item);
}
}
$output[$key] = array_combine($sources, $items);
$count = count($items);
}
else {
drupal_set_message(t('Mismatching results.
......@@ -93,6 +98,7 @@ class FeedsXPathParser extends FeedsParser {
return;
}
}
$batch->setItems($output);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment