protected function FeedsExXml::executeSourceExpression in Feeds extensible parsers 7
Same name and namespace in other branches
- 7.2 src/FeedsExXml.inc \FeedsExXml::executeSourceExpression()
Executes a single source expression.
Parameters
string $machine_name: The source machine name being executed.
string $expression: The expression to execute.
mixed $row: The row to execute on.
Return value
scalar|[]scalar Either a scalar, or a list of scalars. If null, the value will be ignored.
Overrides FeedsExBase::executeSourceExpression
1 method overrides FeedsExXml::executeSourceExpression()
- FeedsExQueryPathXml::executeSourceExpression in src/
FeedsExQueryPathXml.inc - Executes a single source expression.
File
- src/
FeedsExXml.inc, line 81 - Contains FeedsExXml.
Class
- FeedsExXml
- Parses XML documents with XPath.
Code
protected function executeSourceExpression($machine_name, $expression, $row) {
$result = $this->xpath
->evaluate($expression, $row);
if (!$result instanceof DOMNodeList) {
return $result;
}
if ($result->length == 0) {
return;
}
$return = array();
if (!empty($this->config['sources'][$machine_name]['inner'])) {
foreach ($result as $node) {
$return[] = $this
->getInnerXml($node);
}
}
elseif (!empty($this->config['sources'][$machine_name]['raw'])) {
foreach ($result as $node) {
$return[] = $this
->getRaw($node);
}
}
else {
foreach ($result as $node) {
$return[] = $node->nodeValue;
}
}
// Return a single value if there's only one value.
return count($return) === 1 ? reset($return) : $return;
}