Created
July 14, 2015 21:26
-
-
Save hakre/0d83da87ad5781e9bc97 to your computer and use it in GitHub Desktop.
DOMBLAZE II XMLNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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