Xml Serialization library for php.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
XmlDeserializer.php
XmlSerializable.php
XmlSerializer.php
composer.json
functions.php
readme.md

readme.md

XmlSerializer

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>