xref: /PHP-8.4/ext/simplexml/tests/023.phpt (revision 7f2f0c00)
1--TEST--
2SimpleXML: Attributes with entities
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$xml =<<<EOF
9<?xml version='1.0'?>
10<!DOCTYPE talks SYSTEM "nbsp.dtd" [
11<!ELEMENT root  EMPTY>
12<!ATTLIST root  attr1 CDATA #IMPLIED>
13<!ENTITY  nbsp   "&#38;#x00A0;">
14]>
15<root attr='foo&nbsp;bar&nbsp;baz'></root>
16EOF;
17
18$sxe = simplexml_load_string($xml);
19
20var_dump($sxe);
21var_dump($sxe['attr']);
22?>
23--EXPECTF--
24object(SimpleXMLElement)#%d (1) {
25  ["@attributes"]=>
26  array(1) {
27    ["attr"]=>
28    string(%d) "foo%sbar%sbaz"
29  }
30}
31object(SimpleXMLElement)#%d (1) {
32  [0]=>
33  string(%d) "foo%sbar%sbaz"
34}
35