public function toXml($data, $rootNodeName, $xml=null)
{
if (ini_get('zend.ze1_compatibility_mode') == 1){
ini_set ('zend.ze1_compatibility_mode', 0);
}
if ($xml == null){
$node = $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><".$rootNodeName." />");
}else{
$node = $rootNodeName;
}
foreach($data as $key => $value){
if (is_numeric($key)){
$tok = explode('_', $rootNodeName);
$key = $tok[0];
}
if (is_array($value)||is_object($value)){
$node = $xml->addChild($key);
$this->toXml($value,$node,$xml);
}else {
$node->addChild($key,$value);
}
}
return $xml->asXML();
}
{
if (ini_get('zend.ze1_compatibility_mode') == 1){
ini_set ('zend.ze1_compatibility_mode', 0);
}
if ($xml == null){
$node = $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><".$rootNodeName." />");
}else{
$node = $rootNodeName;
}
foreach($data as $key => $value){
if (is_numeric($key)){
$tok = explode('_', $rootNodeName);
$key = $tok[0];
}
if (is_array($value)||is_object($value)){
$node = $xml->addChild($key);
$this->toXml($value,$node,$xml);
}else {
$node->addChild($key,$value);
}
}
return $xml->asXML();
}