Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.21.0

Bug #2688 in simplexml mode $array needs to be non-empty
Submitted: 2004-11-04 15:27 UTC
From: demianturner Assigned: schst
Status: Closed Package: XML_Serializer
PHP Version: 4.3.9 OS: linux fedora core 2
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 36 - 15 = ?

 
 [2004-11-04 15:27 UTC] demianturner
Description: ------------ On line 376 of the current release, when working in simplexml mode, I get unexpected results if my $array is empty. The workaround is to test for non-empty arrays: - if (is_array($array) && $this->options['mode'] == 'simplexml') { + if (is_array($array) && count($array) && $this->options['mode'] == 'simplexml') {

Comments

 [2004-11-05 13:22 UTC] demianturner
input data structure ==================== stdClass Object ( [Actions] => services_overture_action Object ( [GetAccountCategories] => services_overture_command_getaccountcategories Object ( ) [accountId] => 2042524050 ) ) calling code: ============= $serializer = & new XML_Serializer($this->_aSerializerOptions); $status = $serializer->serialize($this->data); // data above if (is_a($status, 'PEAR_Error')) { return $status; } $xml = $serializer->getSerializedData(); expected output: ================ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DTCRequest key="xxx" password="xxx" username="xxx" xmlns="urn:/ows/aws/1.2" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="urn:/ows/aws/1.2 https://x-secure.overture.com/schema/dtc/1.2/dtc_request.xsd"> <Actions accountId="2042524050"> <GetAccountCategories /> </Actions> </DTCRequest> actual output: ============== <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DTCRequest key="xxx" password="xxx" username="xxx" xmlns="urn:/ows/aws/1.2" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="urn:/ows/aws/1.2 https://x-secure.overture.com/schema/dtc/1.2/dtc_request.xsd"> <Actions accountId="2042524050" /> </DTCRequest>
 [2004-11-06 15:52 UTC] schst
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/XML_Serializer