Class: XML_Serializer
Source Location: /XML_Serializer-0.8/Serializer.php
PEAR
|
--XML_Serializer
XML_Serializer class that serializes various structures into an XML document
Author(s):
Version:
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 103]
XML_Serializer class that serializes various structures into an XML document this class can be used in two modes: - create an XML document from an array or object that is processed by other
applications. That means, you can create a RDF document from an array in the
following format:
$data = array( "channel" => array( "title" => "Example RDF channel", "link" => "http://www.php-tools.de", "image" => array( "title" => "Example image", "url" => "http://www.php-tools.de/image.gif", "link" => "http://www.php-tools.de" ), array( "title" => "Example item", "link" => "http://example.com" ), array( "title" => "Another Example item", "link" => "http://example.org" ) ) ); to create a RDF document from this array do the following: require_once 'XML/Serializer.php'; $options = array( "indent" => "\t", // indent with tabs "linebreak" => "\n", // use UNIX line breaks "tagName" => "rdf:RDF", // root tag "defaultTagName" => "item" // tag for values with numeric keys ); $serializer = new XML_Serializer($options); $rdf = $serializer->serialize($data); You will get a complete XML document that can be processed like any RDF document. 2. this classes can be used to serialize any data structure in a way that it can later be unserialized again. XML_Serializer will store the type of the value and additional meta information in attributes of the surrounding tag. This meat information can later be used to restore the original data structure in PHP. If you want XML_Serializer to add meta information to the tags, add "typeHints" => true to the options array in the constructor. Future versions of this package will include an XML_Unserializer, that does the unserialization automatically for you.
Method Detail
Documentation generated on Sat, 1 May 2004 00:39:05 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.
|