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 "\n" . $entry->nodeValue; }
Output for 5.0.0 - 7.1.0
<?xml version="1.0"?> <root> <testnode>some val</testnode> <testnode>some val 2</testnode> </root> test xpath: 2 some val some val 2
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/LWBSV on line 2
Process exited with code 255.
Output for 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/LWBSV on line 2
Output for 4.3.0
Fatal error: Cannot instantiate non-existent class: domdocument in /in/RGXY1 on line 2