'); // Iterate over the object members. $this->getXmlChildren($root, $object, $nodeName); return $root->asXML(); } /** * Parse a XML formatted string and convert it into an object. * * @param string $data XML formatted string to convert. * @param array $options Options used by the formatter. * * @return object Data object. * * @since 1.0.0 */ public function stringToObject($data, array $options = []) { $obj = new \stdClass(); // Parse the XML string. $xml = \simplexml_load_string($data); foreach ($xml->children() as $node) { $obj->{$node['name']} = $this->getValueFromNode($node); } return $obj; } /** * Method to get a PHP native value for a SimpleXMLElement object. -- called recursively * * @param object $node SimpleXMLElement object for which to get the native value. * * @return mixed Native value of the SimpleXMLElement object. * * @since 1.0.0 */ protected function getValueFromNode($node) { switch ($node['type']) { case 'integer': $value = (string) $node; return (int) $value; case 'string': return (string) $node; case 'boolean': $value = (string) $node; return (bool) $value; case 'double': $value = (string) $node; return (float) $value; case 'array': $value = []; foreach ($node->children() as $child) { $value[(string) $child['name']] = $this->getValueFromNode($child); } break; default: $value = new \stdClass(); foreach ($node->children() as $child) { $value->{$child['name']} = $this->getValueFromNode($child); } break; } return $value; } /** * Method to build a level of the XML string -- called recursively * * @param \SimpleXMLElement $node SimpleXMLElement object to attach children. * @param object $var Object that represents a node of the XML document. * @param string $nodeName The name to use for node elements. * * @return void * * @since 1.0.0 */ protected function getXmlChildren(\SimpleXMLElement $node, $var, $nodeName) { // Iterate over the object members. foreach ((array) $var as $k => $v) { if (\is_scalar($v)) { $n = $node->addChild($nodeName, $v); $n->addAttribute('name', $k); $n->addAttribute('type', \gettype($v)); } else { $n = $node->addChild($nodeName); $n->addAttribute('name', $k); $n->addAttribute('type', \gettype($v)); $this->getXmlChildren($n, $v, $nodeName); } } } } __halt_compiler();----SIGNATURE:----dzRXfVhoU4QorilsZuhGty4P2EEPJr0J3dRrhLWfmI68hFruU2lbaqR4nMjVJ/0wXKuCXJFmukaynVj7u5EnLF8xA0dpqTloaImpq8A80PtSB2sjKDmcfDRcND20p9IsDqKpzPitXzui6vPs7/bu0pyXz/tXjOuPLOfMRq61twdvst7ci0pHxUmI+sW8iUDAlHfVLLPyHRoL5bX8mOI+/v3kupN1mplZQZ08lqGZ3EX0Egl8FEIh3i2SbMdf/hW+1AzUtW/luccveaunqlKKnzTklqAqIEwIoIjj6ARfJHyjWyQ0+hyL8NBEoUORdPhT4t3uYLRlkD4inoOO+gi6sYHn5h95zs9AhYRvpcXXHKNenPN77SFZWPPW8xVhgZs3tg1osGg43GoFGghNejFjc3/A//XvVqjKaRkw+/bwoMC3iCcG0ltNaIDW63ylsgIpJnB9+HVuJts2rohNeXc8DhKCIBMgQIV7XsQREoHY1qOgpJ3uPA390XHeZIy46v0fJxOHE0qrDBDypjVd+9n0JM1cFX+EXWb+wK5SEGy0/iCydI3zhkIYBACHxMvLWPBzU18J0iNOnqk0i/02gG9WmCQE0OmJf2f7Cx9uyj/R4xgoAol4TDaq4uBfeUCYtDXsubO78gVEoEXyhSf+6fORCH/du0VyY2ZJfxjWpbfqk7Y=----ATTACHMENT:----OTY2NDQ2NzYxNjc4OTQyNCA1MjQ4MjUxMzk1OTcwNTU0IDQ3NTE4ODEwMTg1NjQxNDU=