+ // Handle warnings and errors when loading invalid HTML.
+ $xml_errors_value = libxml_use_internal_errors(true);
+
+ // If there is a host-specific method to get the xml data, use it!
+ $get_xml_host_method = 'get_xml_' . str_replace(".", "_", $host);
+ if (method_exists($this, $get_xml_host_method)) {
+ $xml_data = call_user_func_array(array($this, $get_xml_host_method), array($html));
+ $xmlDoc->loadXML($xml_data);
+ } else {
+ $xmlDoc->loadHTML($html);
+ }
+
+ foreach (libxml_get_errors() as $xml_error) {
+ $this->log_xml_error($xml_error);
+ }
+ libxml_clear_errors();
+ libxml_use_internal_errors($xml_errors_value);
+
+ return $xmlDoc;
+ }
+
+ public function tweep($src_url) {
+ $url = parse_url($src_url);
+ if (FALSE === $url || empty($url["host"])) {
+ trigger_error("Invalid url: $src_url", E_USER_ERROR);
+ return NULL;
+ }
+
+ $xsltProcessor = $this->load_stylesheet($url["host"]);
+ if (NULL === $xsltProcessor) {
+ return NULL;
+ }
+
+ $html = $this->get_contents($src_url);
+ if (FALSE === $html) {
+ return NULL;
+ }
+
+ $xmlDoc = $this->html_to_xml($html, $url["host"]);
+ if (NULL === $xmlDoc) {
+ return NULL;
+ }
+
+ $output = $xsltProcessor->transformToXML($xmlDoc);