+  /**
+   * Convert json to xml.
+   */
+  private static function jsonToXml($json, $root_node_name) {
+    // Apparently the ObjectNormalizer used afterwards is not able to handle
+    // the stdClass object created by json_decode() with the default setting
+    // $assoc = false; so use $assoc = true.
+    $data = json_decode($json, $assoc = TRUE);
+    if (!$data) {
+      return NULL;
+    }
+
+    $encoder = new XmlEncoder();
+    $normalizer = new ObjectNormalizer();
+    $serializer = new Serializer(array($normalizer), array($encoder));
+
+    $serializer_options = array(
+      'xml_encoding' => "UTF-8",
+      'xml_format_output' => TRUE,
+      'xml_root_node_name' => $root_node_name,
+    );
+
+    $xml_data = $serializer->serialize($data, 'xml', $serializer_options);
+    if (!$xml_data) {
+      trigger_error("Cannot serialize data", E_USER_ERROR);
+      return NULL;
+    }
+
+    return $xml_data;
+  }
+
+  /**
+   * Convert the Instagram content to XML.
+   */
+  private function getXmlInstagramCom($html) {
+    // Extract the json data from the html code.
+    $json_match_expr = '/window._sharedData = (.*);/';
+    $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;
+    }
+
+    return Tweeper::jsonToXml($matches[1], 'instagram');
+  }
+
+  /**
+   * Make the Facebook HTML processable.
+   */
+  private function preprocessHtmlFacebookCom($html) {
+    $html = str_replace('<!--', '', $html);
+    $html = str_replace('-->', '', $html);
+    return $html;
+  }
+
+  /**
+   * Convert the HTML retrieved from the site to XML.
+   */
+  private function htmlToXml($html, $host) {