+ private function json_to_xml($html, $json_match_expr, $rootName) {
+ // pre-process, convert json to XML
+ $ret = preg_match($json_match_expr, $html, $matches);
+ if ($ret !== 1) {
+ trigger_error("Cannot match expression: $json_match_expr\n", E_USER_ERROR);
+ return NULL;
+ }
+
+ $data = json_decode($matches[1]);
+ if (!$data) {
+ return NULL;
+ }
+
+ $serializer_options = array (
+ 'addDecl' => TRUE,
+ 'encoding' => "UTF-8",
+ 'indent' => ' ',
+ 'rootName' => $rootName,
+ );
+
+ $serializer = new XML_Serializer($serializer_options);
+
+ $status = $serializer->serialize($data);
+ if (PEAR::isError($status)) {
+ trigger_error($status->getMessage(), E_USER_ERROR);
+ return NULL;
+ }
+
+ return $serializer->getSerializedData();
+ }
+
+ private function html_to_xml($html, $host) {