xref: /PHP-8.0/ext/simplexml/tests/sxe_001.phpt (revision a555cc0b)
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($xml, 'SimpleXMLIterator'));
29
30?>
31--EXPECTF--
32object(SimpleXMLIterator)#%d (2) {
33  ["@attributes"]=>
34  array(1) {
35    ["id"]=>
36    string(5) "elem1"
37  }
38  ["elem1"]=>
39  object(SimpleXMLIterator)#%d (3) {
40    ["@attributes"]=>
41    array(1) {
42      ["attr1"]=>
43      string(5) "first"
44    }
45    ["comment"]=>
46    object(SimpleXMLIterator)#%d (0) {
47    }
48    ["elem2"]=>
49    object(SimpleXMLIterator)#%d (1) {
50      ["elem3"]=>
51      object(SimpleXMLIterator)#%d (1) {
52        ["elem4"]=>
53        object(SimpleXMLIterator)#%d (1) {
54          ["test"]=>
55          object(SimpleXMLIterator)#%d (0) {
56          }
57        }
58      }
59    }
60  }
61}
62