3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = new DOMDocument(); //$xml->loadXML('<root><node/></root>'); $root = $xml->createElement("root"); $xml->appendChild($root); $xpath = new DOMXpath($xml); $el = $xml->createElement("testnode", "some val"); $root->appendChild($el); $el = $xml->createElement("testnode", "some val 2"); $root->appendChild($el); $xml->formatOutput = true; echo $xml->saveXML(); $entries = $xpath->query("/root/testnode"); echo "test xpath: " . $entries->length; foreach($entries as $entry) { echo $entry->nodeValue; }
Output for 5.0.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<?xml version="1.0"?> <root> <testnode>some val</testnode> <testnode>some val 2</testnode> </root> test xpath: 2some valsome val 2
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/ddgts on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/ddgts on line 2