37 $oXml =
new SimpleXMLElement(
"<?xml version=\"1.0\" encoding=\"utf-8\"?><$sDocument/>");
40 return $oXml->asXml();
52 return simplexml_load_string($sXml);
66 $aElements = is_object($oInput) ? get_object_vars($oInput) : (array) $oInput;
68 foreach ($aElements as $sKey => $mElement) {
69 $oXml = $this->
_addChildNode($oXml, $sKey, $mElement, $sPreferredKey);
85 protected function _addChildNode($oXml, $sKey, $mElement, $sPreferredKey = null)
87 $aAttributes = array();
88 if (is_array($mElement) && array_key_exists(
'attributes', $mElement) && is_array($mElement[
'attributes'])) {
89 $aAttributes = $mElement[
'attributes'];
90 $mElement = $mElement[
'value'];
93 if (is_object($mElement) || is_array($mElement)) {
94 if (is_int(key($mElement))) {
97 $oChildNode = $oXml->addChild($sPreferredKey? $sPreferredKey : $sKey);
102 $oChildNode = $oXml->addChild($sPreferredKey? $sPreferredKey : $sKey, $mElement);
119 $aAttributes = (array) $aAttributes;
120 foreach ($aAttributes as $sKey => $sValue) {
121 $oNode->addAttribute($sKey, $sValue);