Class: XML_Serializer
Source Location: /XML_Serializer-0.18.0/Serializer.php
PEAR
|
--XML_Serializer
Creates XML documents from PHP data structures like arrays, objects or scalars.
Author(s):
Version:
- Release: @package_version@
Copyright:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 387]
Creates XML documents from PHP data structures like arrays, objects or scalars. 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( XML_SERIALIZER_OPTION_INDENT => "\t", // indent with tabs XML_SERIALIZER_OPTION_LINEBREAKS => "\n", // use UNIX line breaks XML_SERIALIZER_OPTION_ROOT_NAME => 'rdf:RDF', // root tag XML_SERIALIZER_OPTION_DEFAULT_TAG => '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 XML_SERIALIZER_OPTION_TYPEHINTS => true to the options array in the constructor.
Class Variables
Method Detail
Documentation generated on Sun, 02 Oct 2005 14:00:13 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.
|