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