'); // 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:----C0bj28wcjo16aS8gzPWN7j148fYg98gr9pfqu+P7Cs447YeBpDpC/RN/D7dqSAB0xhDeh3yJTg2OLBIlsCUkr4hIlNTrP/XYKxjv2LwR/w8hfo/c2L2RvBC2bEcBd1hWP8/0dO15BW5gezaz6oIYpwPoqVT4tlWoyiCHwV0vqGgSMxp8vMKSXpnfn1xMUTZJDP/D/K0r4F6Sh0AFJaeWmQFaVdwnUd4XV/pm2PZbbb59brea823uKbeicvg+1y83Sbj1VrkVHqH6guKr0HGC94CAim2yMZI8a2Pfv00Ko9tbkVHsEDa72q75Bz2N/7uX/RooAj0QCInGc5NnVq5G9coah7+6gEgcvcEeDn/qbD8aqHG0zEN8FbCuS6hIx4VT9DvYseOmUyUf/JjvQT5BchxVzPcg5XimZBrJB25xyNV/0JJb4veUjtE5rNQz8rpViVVS9Yahp48lDnLmJynO6VknA68K52jhBaUCrJksYIS7Ek+qBSbaLeLK6F8l/36GjESWX1pW+nGFy3I8pm08f79vipYycLHsJkNXBCGQWsZImUst+PZlaQXO4+zz3jQqn7x8jmzvlEm1sovkrEje5hnokWmzASGtJ+0MeJCiBWyXGyB6qCF12VDu+dOi8Z+Fqi1H8d3Noz7W4RDurC5dLgU/I8LzSZ6fhTHyckdSgJI=----ATTACHMENT:----NTA0MjU1MzYwMTQwOTkzMCA2MjkyMTA5MzM1ODI0MzcgMjIwODIyMDg2MTkxMjk5