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>'; function f($xml){ foreach ($xml as $key => $value) { var_dump($key, $value->hasChildren(), $value, '============='); if (get_class($value) == 'SimpleXMLIterator') f($value); } } f(new SimpleXMLIterator($s));
Output for 5.3.0 - 5.3.29, 5.5.27 - 5.5.35, 5.6.11 - 7.1.0
string(4) "body" bool(false) 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(13) "=============" string(4) "rows" bool(false) object(SimpleXMLIterator)#7 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#6 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#11 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#10 (0) { } ["italic"]=> object(SimpleXMLIterator)#9 (0) { } ["underlined"]=> object(SimpleXMLIterator)#12 (0) { } } } [1]=> object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#8 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#5 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#6 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#11 (0) { } ["italic"]=> object(SimpleXMLIterator)#12 (0) { } ["underlined"]=> object(SimpleXMLIterator)#9 (0) { } } } string(13) "=============" string(5) "types" bool(false) object(SimpleXMLIterator)#9 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#12 (0) { } ["italic"]=> object(SimpleXMLIterator)#11 (0) { } ["underlined"]=> object(SimpleXMLIterator)#10 (0) { } } string(13) "=============" string(6) "custom" bool(false) object(SimpleXMLIterator)#11 (1) { [0]=> string(31) "this is the example of the text" } string(13) "=============" string(7) "Generic" bool(false) object(SimpleXMLIterator)#12 (2) { ["@attributes"]=> array(1) { ["arch"]=> string(6) "simple" } [0]=> string(31) "this is the example of the text" } string(13) "=============" string(4) "bold" bool(false) object(SimpleXMLIterator)#11 (0) { } string(13) "=============" string(6) "italic" bool(false) object(SimpleXMLIterator)#12 (0) { } string(13) "=============" string(10) "underlined" bool(false) object(SimpleXMLIterator)#11 (0) { } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#9 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } string(13) "=============" string(4) "test" bool(false) object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } string(13) "============="
Output for 5.4.0 - 5.5.26, 5.6.0 - 5.6.10
string(4) "body" bool(false) 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(13) "=============" string(4) "rows" bool(false) object(SimpleXMLIterator)#7 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#6 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#11 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#10 (0) { } ["italic"]=> object(SimpleXMLIterator)#9 (0) { } ["underlined"]=> object(SimpleXMLIterator)#12 (0) { } } } [1]=> object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#8 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#5 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#6 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#11 (0) { } ["italic"]=> object(SimpleXMLIterator)#12 (0) { } ["underlined"]=> object(SimpleXMLIterator)#9 (0) { } } } string(13) "=============" string(5) "types" bool(false) object(SimpleXMLIterator)#9 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#12 (0) { } ["italic"]=> object(SimpleXMLIterator)#11 (0) { } ["underlined"]=> object(SimpleXMLIterator)#10 (0) { } } string(13) "=============" string(6) "custom" bool(false) object(SimpleXMLIterator)#11 (0) { } string(13) "=============" string(7) "Generic" bool(false) object(SimpleXMLIterator)#12 (1) { ["@attributes"]=> array(1) { ["arch"]=> string(6) "simple" } } string(13) "=============" string(4) "bold" bool(false) object(SimpleXMLIterator)#11 (0) { } string(13) "=============" string(6) "italic" bool(false) object(SimpleXMLIterator)#12 (0) { } string(13) "=============" string(10) "underlined" bool(false) object(SimpleXMLIterator)#11 (0) { } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#9 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } string(13) "=============" string(4) "test" bool(false) object(SimpleXMLIterator)#5 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } string(13) "============="
Output for 5.1.2 - 5.2.17
string(4) "body" bool(false) 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(13) "=============" string(4) "rows" bool(false) object(SimpleXMLIterator)#13 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#14 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#17 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#18 (0) { } ["italic"]=> object(SimpleXMLIterator)#19 (0) { } ["underlined"]=> object(SimpleXMLIterator)#20 (0) { } } } [1]=> object(SimpleXMLIterator)#15 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#16 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#22 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#23 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#24 (0) { } ["italic"]=> object(SimpleXMLIterator)#25 (0) { } ["underlined"]=> object(SimpleXMLIterator)#26 (0) { } } } string(13) "=============" string(5) "types" bool(false) object(SimpleXMLIterator)#28 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#29 (0) { } ["italic"]=> object(SimpleXMLIterator)#30 (0) { } ["underlined"]=> object(SimpleXMLIterator)#31 (0) { } } string(13) "=============" string(6) "custom" bool(false) object(SimpleXMLIterator)#33 (1) { [0]=> string(31) "this is the example of the text" } string(13) "=============" string(7) "Generic" bool(false) object(SimpleXMLIterator)#34 (2) { ["@attributes"]=> array(1) { ["arch"]=> string(6) "simple" } [0]=> string(31) "this is the example of the text" } string(13) "=============" string(4) "bold" bool(false) object(SimpleXMLIterator)#33 (0) { } string(13) "=============" string(6) "italic" bool(false) object(SimpleXMLIterator)#34 (0) { } string(13) "=============" string(10) "underlined" bool(false) object(SimpleXMLIterator)#33 (0) { } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#28 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } string(13) "=============" string(4) "test" bool(false) object(SimpleXMLIterator)#22 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } string(13) "============="
Output for 5.0.0 - 5.1.1
string(4) "body" bool(false) 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(13) "=============" string(4) "rows" bool(false) object(SimpleXMLIterator)#13 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#14 (1) { ["types"]=> object(SimpleXMLIterator)#17 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#18 (0) { } ["italic"]=> object(SimpleXMLIterator)#19 (0) { } ["underlined"]=> object(SimpleXMLIterator)#20 (0) { } } } [1]=> object(SimpleXMLIterator)#15 (0) { } } ["test"]=> object(SimpleXMLIterator)#16 (0) { } } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#22 (1) { ["types"]=> object(SimpleXMLIterator)#23 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#24 (0) { } ["italic"]=> object(SimpleXMLIterator)#25 (0) { } ["underlined"]=> object(SimpleXMLIterator)#26 (0) { } } } string(13) "=============" string(5) "types" bool(false) object(SimpleXMLIterator)#28 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#29 (0) { } ["italic"]=> object(SimpleXMLIterator)#30 (0) { } ["underlined"]=> object(SimpleXMLIterator)#31 (0) { } } string(13) "=============" string(6) "custom" bool(false) object(SimpleXMLIterator)#33 (1) { [0]=> string(31) "this is the example of the text" } string(13) "=============" string(7) "Generic" bool(false) object(SimpleXMLIterator)#34 (1) { [0]=> string(31) "this is the example of the text" } string(13) "=============" string(4) "bold" bool(false) object(SimpleXMLIterator)#33 (0) { } string(13) "=============" string(6) "italic" bool(false) object(SimpleXMLIterator)#34 (0) { } string(13) "=============" string(10) "underlined" bool(false) object(SimpleXMLIterator)#33 (0) { } string(13) "=============" string(6) "my-row" bool(false) object(SimpleXMLIterator)#28 (0) { } string(13) "=============" string(4) "test" bool(false) object(SimpleXMLIterator)#22 (0) { } string(13) "============="
Output for 4.3.2 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: simplexmliterator in <b>/in/gpbEH</b> on line <b>21</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: simplexmliterator in <b>/in/gpbEH</b> on line <b>21</b><br />