AW: [PEAR-DEV] [RfC] XML_Serializer

From: Date: Mon, 28 Jul 2003 20:18:12 +0000
Subject: AW: [PEAR-DEV] [RfC] XML_Serializer
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18844@lists.php.net to get a copy of this message
Hi, > How does this package compare to WDDX? These two are completely different things. 1. WDDX is an XML application to interchange data between different applications and/or programming languages. 2. XML_Serializer is only used to serialize any data to a any XML format. It does _not_ check for any types. Let's say, you want to create an RSS feed, and don't want to worry about creating the XML. OK, you could build the structure with DOM, but in PHP4 DOM is slow, buggy and why worry learning DOM, when you know how to work with arrays. Then you just build an array in a format like this: $var = array( "channel" => array( "title" => "myFeed", "link" => "http://pear.php.net" ), array( "title" => "Easy generation of XML documents", "link" => "http://pear.php.net/XML_Serializer" ), array( "title" => "Database abstraction", "link" => "http://pear.php.net/MDB" ), ); Then you just call: $options = array( "indent" => " ", "linebreak" => "\n", "tagName" => "rdf:RDF", "defaultTagName" => "item" ); $string = XML_Serializer::serialize($var, $options); and you get: <rdf:RDF> <channel> <title>myFeed</title> <link>http://pear.php.net</link> </channel> <item> <title>Easy generation of XML documents</title> <link>http://pear.php.net/XML_Serializer</link> </item> <item> <title>Database abstraction</title> <link>http://pear.php.net/MDB</link> </item> </rdf:RDF> You could get the same result with objects for items, channel and all other elements used in the RDF document. It's kinda Sterling's simpleXML but the other way round. It just does what you'd expect it to do. You could use this class to build a WDDX serializer that does not rely on the PHP functions. I developed this class only as a helper class for higher-level XML packages... Stephan

« previous php.pear.dev (#18844) next »