public static function Xml2Json($xml) { $doc = new DOMDocument(); $doc->loadXML($xml); $root = $doc->documentElement; return '{"' . $root->tagName . '":' . MgUtils::DomElementToJson($root) . '}'; }