3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request><body test2="321" test3="987">'. '<rows><my-row test4="564">'. '<types>'. '<custom>this is the example of the text</custom>'. '<Generic arch="simple">this is the example of the text</Generic>'. '<bold/><italic/><underlined/>'. '</types>'. '</my-row><my-row test5="565"/><test hidden="false" ready="true"/></rows>'. '</body></request>'; $obj = new SimpleXmlIterator($s); foreach ($obj as $key => $value) { var_dump($key, $value, '<hr/>'); }
Output for 5.1.2 - 7.1.0
string(4) "body" object(SimpleXMLIterator)#3 (2) { ["@attributes"]=> array(2) { ["test2"]=> string(3) "321" ["test3"]=> string(3) "987" } ["rows"]=> object(SimpleXMLIterator)#4 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#5 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#8 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#9 (0) { } ["italic"]=> object(SimpleXMLIterator)#10 (0) { } ["underlined"]=> object(SimpleXMLIterator)#11 (0) { } } } [1]=> object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#7 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } } string(5) "<hr/>"
Output for 5.0.0 - 5.1.1
string(4) "body" object(SimpleXMLIterator)#3 (1) { ["rows"]=> object(SimpleXMLIterator)#4 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#5 (1) { ["types"]=> object(SimpleXMLIterator)#8 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#9 (0) { } ["italic"]=> object(SimpleXMLIterator)#10 (0) { } ["underlined"]=> object(SimpleXMLIterator)#11 (0) { } } } [1]=> object(SimpleXMLIterator)#6 (0) { } } ["test"]=> object(SimpleXMLIterator)#7 (0) { } } } string(5) "<hr/>"
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/KKTVl on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/KKTVl on line 12