note 86679 modified in function.simplexml-element-addChild by danbrown

From: Date: Wed, 29 Oct 2008 16:00:57 +0000
Subject: note 86679 modified in function.simplexml-element-addChild by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145932@lists.php.net to get a copy of this message
As noted by zspencer at zacharyspencer dot com, addChild with an empty string causes a redundant node to be added. This was screwing up our web services xml->JSON conversion - the following hack seems to fix it, use at your own risk... <?php if($sv == null) { $child = $node->addChild($k, '<blank>'); $child = ''; } else { $node->addChild($k, $sv); } ?> --was-- As noted by zspencer at zacharyspencer dot com, addChild with an empty string causes a redundant node to be added. This was screwing up our web services xml->JSON conversion - the following hack seems to fix it, use at your own risk... if($sv == null) { $child = $node->addChild($k, '<blank>'); $child = ''; } else { $node->addChild($k, $sv); } http://php.net/manual/en/function.simplexml-element-addChild.php

« previous php.notes (#145932) next »