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->nodeValue); //$html = $dom->saveXML($book); //print_r($html); ?>
based on t3pS6
Output for 5.6.0 - 7.3.0alpha1
string(29) " ... ... "