--TEST-- SPL: SimpleXMLIterator and recursion --SKIPIF-- --FILE-- Plain text. Bla bla 1. Here we have some text data. And here some more. Wow once again. Bla bla 2. Foo Bar EOF; $sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) { var_dump($name); var_dump(get_class($data)); var_dump(trim($data)); } echo "===DUMP===\n"; var_dump(get_class($sxe)); var_dump(trim($sxe->elem1)); ?> --EXPECT-- string(5) "elem1" string(17) "SimpleXMLIterator" string(10) "Bla bla 1." string(5) "elem2" string(17) "SimpleXMLIterator" string(28) "Here we have some text data." string(5) "elem3" string(17) "SimpleXMLIterator" string(19) "And here some more." string(5) "elem4" string(17) "SimpleXMLIterator" string(15) "Wow once again." string(6) "elem11" string(17) "SimpleXMLIterator" string(10) "Bla bla 2." string(7) "elem111" string(17) "SimpleXMLIterator" string(7) "Foo Bar" ===DUMP=== string(17) "SimpleXMLIterator" string(10) "Bla bla 1."