FeedImportDomXPathReader.php in Feed Import 8
File
feed_import_base/src/FeedImportDomXPathReader.php
View source
<?php
namespace Drupal\feed_import_base;
abstract class FeedImportDomXPathReader extends FeedImportReader {
protected $xpath;
protected $xpathRegisterNodeNS = TRUE;
public function map(&$item, &$path) {
$values = $this->xpath
->evaluate($path, $item, $this->xpathRegisterNodeNS);
if ($values instanceof DOMNodeList) {
if (!($len = $values->length)) {
return NULL;
}
elseif ($len == 1) {
return $values
->item(0)->nodeValue;
}
$i = 0;
$ret = array();
while ($i < $len) {
$ret[] = $values
->item($i++)->nodeValue;
}
return $ret;
}
return $values;
}
}