3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = '<user><prop name="A"><sub name="X"></sub></prop><prop name="B"><sub name="Y"></sub></prop></user>'; $xml = new DomDocument; $xml->loadXML($data); $xpath = new DomXpath($xml); $subY = $xpath->query('//sub[@name="Y"]'); foreach( $subY as $subY ){ $design = $xml->createElement('design'); $design->setAttribute('name', 'J'); $design->setAttribute('path', 'folder'); $subY->appendChild($design); } $xml->formatOutput = true; $xml->preserveWhiteSpace = fals echo $xml->saveXML();
Output for 5.4.0 - 5.4.20
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/Dl2ip on line 23
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_ECHO in /in/Dl2ip on line 23
Process exited with code 255.