XML_Serializer - flexible node attributes?

From: Date: Mon, 12 Dec 2005 22:02:24 +0000
Subject: XML_Serializer - flexible node attributes?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22222@lists.php.net to get a copy of this message
Hello list and thank you advance for the help. I am currently learning about some of the Pear XML packages out there. I need to be able to serialize and unserialize and thought that XML_Serialize was the package for me. That was until I discovered that XML_Serialize is all or nothing when it comes to attributes. I want to produced a mixed document as I saw in the archive from August 2004: ---->>> for instance, i'm trying to create the following XML doc: <?xml version="1.0"> <books> <book id="455" lang="en">
     <author email="jim@nowhere.org">Jim</author>
     <title alt="more stuff">stuff</title>
</book> ... </books> ---->>> The above example has a mix of node attributes (email) and nodes (author's name). I haven't been able to figure out how to make that happen in XML_Serialize. Is it possible now? Someone had responded to the thread, explaining that they should use XML_FastCreate instead. ---->>> XML_Serializer wasn't really made to do that sort of thing. You'd be better off using XML_FastCreate if all you want to do is crank out an XML document. require_once 'XML/FastCreate.php'; $x =& XML_FastCreate::factory('Text'); $x->books(
     $x->book(array('id' => '455', 'lang' => 'en'),
         $x->author(array('email' => 'jim@nowhere.org'), 'Jim'),
         $x->title(array('alt' => 'more stuff'), 'stuff')
     )
); $x->toXML(); ---->>> This is great, however, I also want to be able to decode XML documents which are also mixed. Will the Unserialize class in XML_Serialize allow me do this or should I be looking elsewhere? Thanks, Stephen

« previous php.pear.general (#22222) next »