3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str='<root> <book id="1"> <title>..1.</title> <author>.1..</author> </book> <book id="2"> <title>.2..</title> <author>.2..</author> </book> <book id="3"> <title>.3..</title> <author>.3..</author> </book> </root>'; $dom = new DOMDocument; $dom->loadXML($str); $xpath = new DOMXPath($dom); $book = $xpath->query("//book[@id='3']")->item(0); //echo $book->title; foreach($book->childNode as $node) { $pattern = "/<'title'>(.*)<\/'title'>/"; preg_match($pattern, $node, $matches, PREG_OFFSET_CAPTURE); echo $matches; } //echo $html; ?>
based on LVf6v
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0alpha1
Notice: Undefined property: DOMElement::$childNode in /in/gWsYY on line 22 Warning: Invalid argument supplied for foreach() in /in/gWsYY on line 22
Output for hhvm-3.15.4
Notice: Undefined property: DOMElement::$childNode in /in/gWsYY on line 22 Warning: Invalid argument supplied for foreach() in /in/gWsYY on line 26