kadet / xml-serializer
PHP Xml Serializer, with annotation support.
v1.0.0
2014-04-19 23:19 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-10-29 01:57:10 UTC
README
Xml Serialization library for PHP >= 5.3. It allows to serialize object, arrays and scalars into xml, with only few LoC.
Author: Kacper "Kadet" Donat, Some Rights Reserved. License: Creative Commons 4.0 BY-SA
Features
- Support for annotations, more in wiki
- Custom serialization and deserialization mechanisms by
XmlSerializable
interface, more in wiki.
Example
$serializer = new Kadet\XmlSerializer\XmlSerializer(); echo $serializer->serialize((object)array( 'foo' => 'bar', 'array' => array(1, 2, 3, 4, 'key' => 'value'), 'obj' => (object)array('bar' => 'foo') ), 'object');
Outputs:
<?xml version="1.0" encoding="utf-8"?> <object xmlns:s="urn:kadet:serializer"> <foo>bar</foo> <array s:type="array"> <element s:key="0">1</element> <element s:key="1">2</element> <element s:key="2">3</element> <element s:key="3">4</element> <element s:key="key">value</element> </array> <obj> <bar>foo</bar> </obj> </object>