To give you a general idea:
<?php
require_once "ObjectXMLConvertor.php";
require_once "XMLUtil.php";
class Ape {
private $ant;
var $dog = "<{}\"'[]>";
var $fox;
function __construct() {
$this->fox = array("test1" => 77, 5 => array(), 99);
$this->ant = true;
}
function __sleep() {
return array_keys(get_object_vars($this));
}
}
class Box extends Ape {
protected $cow = 3.2;
var $eer = 2;
private $eel;
private $ant = 53;
function __construct() {
parent::__construct();
$this->eel= fopen('XMLUtil.php', 'r');
$this->eer = array(new Ape());
}
function __sleep() {
unset($this->eel);
return array_merge(array_keys(get_object_vars($this)), parent::__sleep());
}
function __wakeup() {
$this->eel = fopen('boot.php', 'r');
parent::__wakeup();
}
}
$xml = ObjectXMLConvertor::phpToXml(new Box(), "box");
$xml = XMLUtil::niceXML($xml);
header("Content-type: text/xml");
echo $xml;
?>
Result:
<box php:class="Box" xmlns:php="http://www.php.net/">
<cow>3.2</cow>
<eer>
<php:element php:class="Ape" php:id="0">
<ant>1</ant>
<dog><{}"'[]></dog>
<fox>
<test1>77</test1>
<php:element php:id="5"></php:element>
<php:element php:id="6">99</php:element>
</fox>
</php:element>
</eer>
<ant>53</ant>
<ant php:inclass="Ape">1</ant>
<dog><{}"'[]></dog>
<fox>
<test1>77</test1>
<php:element php:id="5"></php:element>
<php:element php:id="6">99</php:element>
</fox>
</box>