xref: /PHP-7.2/ext/simplexml/tests/010.phpt (revision 17ccbeec)
1--TEST--
2SimpleXML: Simple Inheritance
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
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===DONE===
33--EXPECTF--
34object(simplexml_inherited)#%d (2) {
35  ["@attributes"]=>
36  array(1) {
37    ["id"]=>
38    string(5) "elem1"
39  }
40  ["elem1"]=>
41  object(simplexml_inherited)#%d (3) {
42    ["@attributes"]=>
43    array(1) {
44      ["attr1"]=>
45      string(5) "first"
46    }
47    ["comment"]=>
48    object(simplexml_inherited)#%d (0) {
49    }
50    ["elem2"]=>
51    object(simplexml_inherited)#%d (1) {
52      ["elem3"]=>
53      object(simplexml_inherited)#%d (1) {
54        ["elem4"]=>
55        object(simplexml_inherited)#%d (1) {
56          ["test"]=>
57          object(simplexml_inherited)#%d (0) {
58          }
59        }
60      }
61    }
62  }
63}
64===DONE===
65