vote up 0 vote down
star

We are using pear's xml serializer to turn our request arrays into XML to submit to other servers for an XML response.

The problem is, for one of the attributes we will need to submit an XML similar to this

<totalRooms>
  <Room>
    ...
  </Room>
  <Room>
    ...
  </Room>
</totalRooms>

How do we compile this in PHP arrays so the Serializer produces the correct XML?

ie, we need:

Array("totalRooms" =>

Array("Room" => ...)

Array("Room" => ...)

)

Currently will not work because of the shared Key names "Room" end up overwriting each other... is there any other method?

flag
what serializer are you using? – Mez Apr 6 at 21:34
php-pear serializer version 0.19.2 – shudson250 Apr 6 at 22:12
add comment

2 Answers

vote up 0 vote down

Just making a guess, here, but from what I read from the doc, if you only have "room" unnamed and no further unnamed inner lists.

Would work and be serialized okay as long as you set the defaultTagName option using $serializer->setOption("defaultTagName", 'Room');

That being done, the following would serialize

    array("totalRooms" =>
      array(
        array("Room" => ...),
        array("Room" => ...),
        array("Room" => ...)
            )
         )
link|flag
add comment
vote up 0 vote down
check

We've taken this job from the server and given it to Flash (client-side platform), making the problem much easier to handle.

Thank you Mr.Zombie for your response.

link|flag
add comment

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.