Skip to content

Instantly share code, notes, and snippets.

@hakre hakre/domblaze2.php
Created Jul 14, 2015

Embed
What would you like to do?
DOMBLAZE II XMLNS
<?php
/**
* DOMBLAZE II is just with XMLNS support
*
* @link http://stackoverflow.com/a/26327033/367456
*/
/* DOMBLAZE II XMLNS */ $doc->registerNodeClass("DOMElement", "DOMBLAZE");
class DOMBLAZE extends DOMElement
{
/**
* @param $expression
*
* @return DomNode|DOMXPath|IteratorIterator|String|DOMElement[]
*/
public function __invoke($expression = null)
{
return $this->xpath($expression);
}
/**
* @param string $expression [optional]
*
* @return IteratorIterator|DOMXPath|DomNode|String|DOMElement[]
*/
function xpath($expression = null)
{
isset($this->ownerDocument->xpath) || $this->ownerDocument->xpath = new DOMXPath($this->ownerDocument);
if ($expression === null) {
return $this->ownerDocument->xpath;
}
$result = $this->ownerDocument->xpath->evaluate($expression, $this);
return ($result instanceof DOMNodeList) ? new IteratorIterator($result) : $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.