xref: /PHP-8.4/ext/simplexml/tests/009.phpt (revision 7f2f0c00)
1--TEST--
2SimpleXML: foreach
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7$sxe = simplexml_load_string(<<<EOF
8<?xml version='1.0'?>
9<!DOCTYPE sxe SYSTEM "notfound.dtd">
10<sxe id="elem1">
11 Plain text.
12 <elem1 attr1='first'>
13  Bla bla 1.
14  <!-- comment -->
15  <elem2>
16   Here we have some text data.
17   <elem3>
18    And here some more.
19    <elem4>
20     Wow once again.
21    </elem4>
22   </elem3>
23  </elem2>
24 </elem1>
25 <elem11 attr2='second'>
26  Bla bla 2.
27 </elem11>
28</sxe>
29EOF
30);
31foreach($sxe->children() as $name=>$val) {
32    var_dump($name);
33    var_dump(get_class($val));
34    var_dump(trim($val));
35}
36?>
37--EXPECT--
38string(5) "elem1"
39string(16) "SimpleXMLElement"
40string(10) "Bla bla 1."
41string(6) "elem11"
42string(16) "SimpleXMLElement"
43string(10) "Bla bla 2."
44