public function XpathDomXpath::__construct in Feeds extensible parsers 8
Constructs a XpathDomXpath object.
@todo Add an option to force a deep scan of namespaces.
Parameters
\DOMDocument $document: The DOM document to parse.
File
- src/
XpathDomXpath.php, line 29
Class
- XpathDomXpath
- Wraps DOMXPath simplifying usage.
Namespace
Drupal\feeds_exCode
public function __construct(DOMDocument $document) {
$this->xpath = new DOMXPath($document);
// Find all namespaces.
// Calling simplexml_import_dom() and SimpleXML::getNamespaces() is several
// orders of magnitude faster than searching for the namespaces ourselves
// using XPath.
$simple = simplexml_import_dom($document);
// An empty DOMDocument will make $simple NULL.
if ($simple === NULL) {
return;
}
foreach ($simple
->getNamespaces(TRUE) as $prefix => $namespace) {
$this->xpath
->registerNamespace($prefix, $namespace);
}
}