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