xref: /PHP-7.0/ext/simplexml/tests/sxe_001.phpt (revision 610c7fbe)
1--TEST--
2SPL: SimpleXMLIterator
3--SKIPIF--
4<?php
5if (!extension_loaded("simplexml")) print "skip SimpleXML not present";
6if (!extension_loaded("libxml")) print "skip LibXML not present";
7?>
8--FILE--
9<?php
10
11$xml =<<<EOF
12<?xml version='1.0'?>
13<!DOCTYPE sxe SYSTEM "notfound.dtd">
14<sxe id="elem1">
15 <elem1 attr1='first'>
16  <!-- comment -->
17  <elem2>
18   <elem3>
19    <elem4>
20     <?test processing instruction ?>
21    </elem4>
22   </elem3>
23  </elem2>
24 </elem1>
25</sxe>
26EOF;
27
28var_dump(simplexml_load_string((binary)$xml, 'SimpleXMLIterator'));
29
30?>
31===DONE===
32--EXPECTF--
33object(SimpleXMLIterator)#%d (2) {
34  ["@attributes"]=>
35  array(1) {
36    ["id"]=>
37    string(5) "elem1"
38  }
39  ["elem1"]=>
40  object(SimpleXMLIterator)#%d (3) {
41    ["@attributes"]=>
42    array(1) {
43      ["attr1"]=>
44      string(5) "first"
45    }
46    ["comment"]=>
47    object(SimpleXMLIterator)#%d (0) {
48    }
49    ["elem2"]=>
50    object(SimpleXMLIterator)#%d (1) {
51      ["elem3"]=>
52      object(SimpleXMLIterator)#%d (1) {
53        ["elem4"]=>
54        object(SimpleXMLIterator)#%d (1) {
55          ["test"]=>
56          object(SimpleXMLIterator)#%d (0) {
57          }
58        }
59      }
60    }
61  }
62}
63===DONE===
64