|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-05-13 08:53 UTC] chregu@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Description: ------------ When using getAttribute to get the value of an attribute that contains an XML entity (eg. ®) the returned value is neither the actual character that is being represented nor the characters that make up the entity '&' '#' '1' '7' '4'. Instead there are two characters that are returned, A circumflex (Â) and, in this example, the registered trademark symbol (®). './configure' '--prefix=/opt/php5' '--with-mysql' '--with-apxs2=/usr/sbin/apxs2' '--with-zlib' '--with-expat' '--enable-sigchild' '--with-openssl' '--enable-shared' '--enable-soap' '--with-gd' '--enable-mbstring' '--with-pgsql' '--with-imap=shared,/usr/lib' '--with-imap-ssl=no' '--with-gd' '--with-jpeg-dir=/usr/include' '--with-ldap' '--with-xsl' '--enable-memory-limit' '--enable-debug' '--with-libxml-dir=/usr' Reproduce code: --------------- ent.php: $dom = new DomDocument(); $dom->substituteEntities = true; $dom->resolveExternals = true; $dom->load('ent.xml'); $dom->substituteEntities = true; $dom->resolveExternals = true; echo $dom->saveXml(); $list = $dom->getElementsByTagName('bar'); $node = $list->item(0); echo "\n===\n Attribute 'test' of node 'bar': "; echo $node->getAttribute("test"); echo "\n===\n Attribute 'test' of node 'bar' with htmlentities: "; echo htmlentities($node->getAttribute("test")); echo "\n===\n"; ent.xml: <?xml version="1.0"?> <!DOCTYPE foo [ <!ENTITY reg "®"> ]> <foo> <bar test="®">®</bar> </foo> Expected result: ---------------- <?xml version="1.0"?> <!DOCTYPE foo [ <!ENTITY reg "®"> ]> <foo> <bar test="®">®</bar> </foo> === Attribute 'test' of node 'bar': ® === Attribute 'test' of node 'bar' with htmlentities: &#174; === Actual result: -------------- <?xml version="1.0"?> <!DOCTYPE foo [ <!ENTITY reg "®"> ]> <foo> <bar test="®">®</bar> </foo> === Attribute 'test' of node 'bar': ® === Attribute 'test' of node 'bar' with htmlentities: ® ===