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