3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ReadXml($xmlstr) { $xml = new \SimpleXmlElement($xmlstr); $result = $xml->getName() . PHP_EOL; foreach ($xml as $child) { $result .= $child->getName() . ': ' . $child . PHP_EOL; } return $result; } $xmlstr= '<Address><to>James</to><from>Jani</from><heading>Reminder</heading><body>Please check your mail.</body></Address>'; echo ReadXml($xmlstr);
Output for 5.3.0 - 7.1.0
Address to: James from: Jani heading: Reminder body: Please check your mail.
Output for 5.1.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/64TnH on line 5 Address to: James from: Jani heading: Reminder body: Please check your mail.
Output for 5.0.0 - 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/64TnH on line 5 Fatal error: Call to undefined method SimpleXMLElement::getName() in /in/64TnH on line 6
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/64TnH on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/64TnH on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/64TnH on line 5 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/64TnH on line 5