|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-03-19 12:22 UTC] vesko at webstudiobulgaria dot com
Description:
------------
There is a difference in the way the html entities are handled when the new nodes are assigned in different ways. In case of using addChild method they are decoded, otherwise not.
Reproduce code:
---------------
$xml_element = new simpleXMLElement('<root></root>');
$xml_element->node1 = 'a & b';
$xml_element->addChild('node2','c & d');
print $xml_element->node1;
print $xml_element->node2;
Expected result:
----------------
a & bc & d//both left
or
a & bc & d//both decoded
Actual result:
--------------
a & bc & d//one left and the other decoded
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Based on: $xml_element = new simpleXMLElement('<root></root>'); $xml_element['attrib1'] = 'a & b'; $xml_element->addAttribute('attrib2','c & d'); print $xml_element['attrib1']; print $xml_element['attrib2']; which gives: a & bc & d I guess the correct behaviour is to leave the entities as they are, so in the previous example addChild() gives the wring result.Hi Felipe, Thanks for the patch. I've tested it against 5.2.5 source. It fixes the case: $xml_element->addChild('node2','c & d'); but not the case: $xml_element->node1[0] = 'a & b';//still decodes