xref: /PHP-7.0/ext/simplexml/tests/009.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML: foreach
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
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===DONE===
38--EXPECT--
39string(5) "elem1"
40string(16) "SimpleXMLElement"
41string(10) "Bla bla 1."
42string(6) "elem11"
43string(16) "SimpleXMLElement"
44string(10) "Bla bla 2."
45===DONE===
46