Bug #76712 [NEW]: Empty Tags are preserved if node value is overwritten with empty value

From: Date: Mon, 06 Aug 2018 14:22:14 +0000
Subject: Bug #76712 [NEW]: Empty Tags are preserved if node value is overwritten with empty value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216638@lists.php.net to get a copy of this message
From: frank dot mohaupt at brainworx dot audio Operating system: Linux d45011cc91b7 4.9.93-boot2d PHP version: 7.0.31 Package: SimpleXML related Bug Type: Bug Bug description:Empty Tags are preserved if node value is overwritten with empty value Description: ------------ If the value of node "foo" is empty while adding the node, its output (SimpleXMLElement::asXML()) is "<foo/>". If the value of node "foo" is overwritten with an empty value ($sxe->foo = ''), its output is "<foo></foo>" instead of "<foo/>". Test script: --------------- $sxe = new SimpleXMLElement('<foo></foo>'); $sxe->addChild('bar'); $arrResults['empty node'] = $sxe->asXML(); $sxe = new SimpleXMLElement('<foo></foo>'); $sxe->addChild('bar', ''); $arrResults['empty string'] = $sxe->asXML(); $sxe = new SimpleXMLElement('<foo></foo>'); $sxe->addChild('bar'); $sxe->bar = ''; $arrResults['overwritten empty string'] = $sxe->asXML(); foreach($arrResults as $key => $strResult){ echo $key . ': ' . $strResult; } // output // empty node: <?xml version="1.0"?>\n<foo><bar/></foo>\n // empty string: <?xml version="1.0"?>\n<foo><bar/></foo>\n // overwritten empty string: <?xml version="1.0"?>\n<foo><bar></bar></foo>\n Expected result: ---------------- I expect to get the same result for all three cases. -- Edit bug report at https://bugs.php.net/bug.php?id=76712&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76712&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76712&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76712&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76712&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76712&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76712&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76712&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76712&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76712&r=support Expected behavior: https://bugs.php.net/fix.php?id=76712&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76712&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76712&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76712&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76712&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76712&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76712&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76712&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76712&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76712&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76712&r=mysqlcfg

« previous php.bugs (#216638) next »