static function toXml($json, $objOption) { $obj = array('name' => $objOption[Request::BODY_TAG], 'attributes' => array('xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema", 'MajorVersion' => 3, 'xmlns' => 'http://www.nrf-arts.org/IXRetail/namespace/')); $header = array(); $header['name'] = 'ARTSHeader'; $header['attributes'] = array('MessageType' => 'Request'); $header[] = array('name' => 'DateTime', 'value' => date('c')); if ($objOption[Request::HEADER_OPTION]) { $header['attributes'] = array_merge($header['attributes'], $objOption[Request::HEADER_OPTION]); } $header[] = $objOption[Request::HEADER_CONTENT]; $obj[] = $header; $body = array(); $body['name'] = 'CustomerBody'; $body['attributes'] = $objOption[Request::BODY_OPTION]; $body = array_merge($body, Request::parseArray(Request::toArray($json))); $obj[] = $body; $doc = new DOMDocument(); $child = Request::generate_xml_element($doc, $obj); if ($child) { $doc->appendChild($child); } $doc->formatOutput = true; // Add whitespace to make easier to read XML $xml = $doc->saveXML(); return $xml; }