From:             erudd at netfor dot com
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     SimpleXML related
Bug description:  SimpleXML interface incosnsistent

Description:
------------
Referencing bug #44458

Where in the documentation does it state that the strings must be escaped
when setting attributes or assigning values to children. I can find it
nowhere in the documentation, nor any examples where you show that you
"must escape text content" before entering it into the attribute or text
content of an element.

Also this behavior is inconsistent behavior as when you fetch the data it
is NOT escaped. So why should I need to escape the data when putting it
in?

This makes simpleXML not so simple as I have to perform extra "unexpected"
work while storing data into the xml document.  Which I do not have to do
with the DOM extension.

Consistency should be high priority in this.. I should expect to retrieve
the same value out that I put in. the SimpleXML class should handle
encoding and decoding data for me so "I" don't have to think about it.

Reproduce code:
---------------
$sxml=new SimpleXMLElement('<test></test>');
$sxml->addChild('child1','One & Two');
echo "Test 1:".(string)$sxml->child1."\n";

$sxml->addChild('child2','One &amp; Two');
echo "Test 2:".(string)$sxml->child2."\n";

$sxml->addChild('child3');
$sxml->child3 = 'One &amp; Two';
echo "Test 3:".(string)$sxml->child3."\n";


Expected result:
----------------
Test 1:One & Two
Test 2:One &amp; Two
Test 3:One &amp; Two

Actual result:
--------------
Test 1:One 
Test 2:One & Two
Test 3:One & Two


-- 
Edit bug report at http://bugs.php.net/?id=45253&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45253&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45253&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45253&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45253&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45253&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45253&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45253&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45253&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45253&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45253&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45253&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45253&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45253&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45253&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45253&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45253&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45253&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45253&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45253&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45253&r=mysqlcfg

Reply via email to