xref: /PHP-7.1/ext/simplexml/tests/023.phpt (revision 7af945e2)
1--TEST--
2SimpleXML: Attributes with entities
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
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===DONE===
24--EXPECTF--
25object(SimpleXMLElement)#%d (1) {
26  ["@attributes"]=>
27  array(1) {
28    ["attr"]=>
29    string(%d) "foo%sbar%sbaz"
30  }
31}
32object(SimpleXMLElement)#%d (1) {
33  [0]=>
34  string(%d) "foo%sbar%sbaz"
35}
36===DONE===
37