3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data=' <root> <element> <feed id="9"> <title>test</title> <table>feeds</table> <link/> <feed_type>API</feed_type> <affiliate/> <mwst>ja</mwst> <tld>DE</tld> <query/> </feed> <feed id="10"> <title>test</title> <table>feeds</table> <link/> <feed_type>API</feed_type> <affiliate/> <mwst>ja</mwst> <tld>DE</tld> <query/> </feed> </element> </root>'; function deleteNode($feed_id) { global $xml; $doc = new SimpleXMLElement($data); foreach($doc->feed as $feed){ if($feed['id'] == $feed_id) { $dom=dom_import_simplexml($feed); $dom->parentNode->removeChild($dom); } } } echo "\n"; deleteNode("10"); echo $xml->asXML();
based on tHElt
Output for 7.0.0 - 7.1.0
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught Exception: String could not be parsed as XML in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.4 - 5.6.21
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.3
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(30): SimpleXMLElement->__construct('') #1 /in/jZa5O(39): deleteNode('10') #2 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Notice: Undefined variable: data in /in/jZa5O on line 30 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /in/jZa5O:30 Stack trace: #0 /in/jZa5O(39): deleteNode('') #1 {main} thrown in /in/jZa5O on line 30
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/jZa5O on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/jZa5O on line 30