Edit report at http://bugs.php.net/bug.php?id=52553&edit=1
ID: 52553 Updated by: fel...@php.net Reported by: dataget2001 at yahoo dot co dot jp Summary: the result is different between php versions Status: Assigned Type: Bug Package: SimpleXML related PHP Version: Irrelevant Assigned To: rrichards Block user comment: N New Comment: The bug related to this stuff is the bug #44478 According to the test committed for the mentioned bug (http://svn.php.net/viewvc/php/php-src/trunk/ext/simplexml/tests/bug44478.phpt?revision=255607&view=markup) it seems expected. To get the expected behavior, use addChild(). <?php $xml_element = new simpleXMLElement('<root></root>'); $xml_element->addchild('node1', 'a & b'); var_dump($xml_element->node1); /* object(SimpleXMLElement)#2 (1) { [0]=> string(5) "a & b" } */ Previous Comments: ------------------------------------------------------------------------ [2010-09-11 18:11:30] fel...@php.net This report remember another report. Need to find it. ------------------------------------------------------------------------ [2010-08-06 10:43:48] dataget2001 at yahoo dot co dot jp Description: ------------ the result of test script below is different between php version 5.1.6 and version 5.3.2. Test script: --------------- <?php var_dump(phpversion()); $foo1 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root />'); $foo1->addChild("x", htmlspecialchars("<test />")); $foo2 = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root><x /></root>'); $foo2->x = htmlspecialchars("<test />"); var_dump($foo1->x); var_dump($foo2->x); var_dump($foo1->asXML() === $foo2->asXML()); ?> Expected result: ---------------- string(5) "5.1.6" object(SimpleXMLElement)#3 (1) { [0]=> string(8) "<test />" } object(SimpleXMLElement)#3 (1) { [0]=> string(8) "<test />" } bool(true) Actual result: -------------- string(5) "5.3.2" object(SimpleXMLElement)#3 (1) { [0]=> string(8) "<test />" } object(SimpleXMLElement)#3 (1) { [0]=> string(14) "<test />" } bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52553&edit=1