I collect some data in xml format through an API and would like to deserialize it in an objects list. I\'m using Symfony2 and find out JMSSerializerBundle but I do not reall
Due to the nature of XML, the exact thing you want, is not possible. You would always need something to translate object -> xml and xml -> object.
My suggestion to you would be a class that works as collection and takes care of it for you, holding the list of objects as property, which can be created from an xml input and create xml output from existing objects.
An alternativ (if you don't really need to have it as xml anymore) would be to simply serialize the objects and store them that way, or searialize an array (or collection object) if you want them all at once. The plain serialize() and unserialize() functions from PHP will do the trick there. Since it's data only, you don't even need the methods serialize and unserialize in your class.
Update: If it's only take the XML into an object, then simplexml already has you covered: http://www.php.net/manual/en/function.simplexml-load-string.php
The second parameter is class name.
Quote: You may use this optional parameter so that simplexml_load_string() will return an object of the specified class. That class should extend the SimpleXMLElement class.
If only this is your goal, then simplexml does it already.
Update 2: I've read some more into the bundle. It does NOT do what you want. It takes an object and the serializes it into XML/YAML, and then of course reverses that process again from those serialized states. It cannot take some random XML file and turn that into a perfect object for you.