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

Doc Bug #18395 problem adding items with same name
Submitted: 2011-03-24 17:35 UTC
From: nadeemshafi9 Assigned:
Status: Open Package: XML_Serializer (version SVN)
PHP Version: 5.3.0 OS: centos
Roadmaps: (Not assigned)    
Subscription  


 [2011-03-24 17:35 UTC] nadeemshafi9 (Nadeem Shafi)
Description: ------------ hi guys im using the pear xml serializer but i am running into a problem, i have a framework for an API which i use to create an array and then output as xml with xml serializer. The issue i have run into: i define a default tag before i create an array so my array is for example array( "a" "b" ) both of these will get labeled video in there xml thats fine <video>a</video> <video>b</video> ok so i have a whole bunch of "videos" with there _attributes set. inside each video i need multiple media elements <media x=2>x</media> <media x=4>x</media> <media x=5>x</media> my problem is that you cant add multiple items to an array with the same Key. array( "media" => x, "media" => x, "media" => x ) and if i let it default then the default tag is video plus i cant set the _attributes of the tag unless i make the value of the key into an array eg. array( "media" => array("_aributes" => array("x" => 1), "mediaValue" => "x"), "media" => array("_aributes" => array("x" => 2), "mediaValue" => "x"), "media" => array("_aributes" => array("x" => 2), "mediaValue" => "x") ) this will give me <media x=2><mediaValue>x</mediaValue></media> <media x=4><mediaValue>x</mediaValue></media> <media x=5><mediaValue>x</mediaValue></media> at the moment i get <video> <media x=2><mediaValue>x</mediaValue></media> </video> <video> <media x=4><mediaValue>x</mediaValue></media> </video> <video> <media x=5><mediaValue>x</mediaValue></media> </video> i want to get <media x=2>x</media> <media x=4>x</media> <media x=5>x</media> any help ? thanks im relay stuck on this one plus my API framework has constraints because it initializes the serializer at the end and inserts the array and parses outputs it even an injection work around would be good but the serializer seems to convert all tags into html char codes regards

Comments

 [2011-03-25 03:15 UTC] nadeemshafi9 (Nadeem Shafi)
i fixed it !! You have to tell the constructor with option use simpleXml $serializer(array( 'mode' => 'simplexml', 'defaultTagName' => array(parent => child, parent => child) )); options Mode