3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str='<root> <book id="1"> <title id="aaa">...</title> <author>...</author> </book> <book id="2"> <title>...</title> <author>...</author> </book> <book id="3"> <title>...</title> <author>...</author> </book> </root>'; $dom = new DOMDocument; $dom->loadXML($str); $xpath = new DOMXPath($dom); $book = $xpath->query("//book[@id='2']")->item(0); var_dump($book->ownerDocument->innerHTML); //$html = $dom->saveXML($book); //print_r($html); ?>
based on qef15
Output for 5.6.0 - 7.3.0alpha1
Notice: Undefined property: DOMDocument::$innerHTML in /in/2AEaC on line 21 NULL