47
Isn't that an inconsistent behavior? (PHP 5.2.6)
<?php
$a = new SimpleXMLElement('<a/>');
$a->addAttribute('b', 'One & Two');
//$a->addChild('c', 'Three & Four'); -- results in "unterminated entity reference" warning!
$a->addChild('c', 'Three & Four');
$a->d = 'Five & Six';
print($a->asXML());
Renders:
<?xml version="1.0"?>
<a b="One & Two">
<c>Three & Four</c>
<d>Five & Six</d>
</a>
At bugs.php.net they reject all the submissions about that, saying it's a feature. Why could that possibly be? BTW, there's nothing in the docs about that discrepancy of escaping text values by SimpleXMLElement.
Can anyone convince me it's the best API design decision possible?