/** * Get a remote document and transform to DomXMLDocument * @param string $url * @return handle \DOMDocument */ public static function GetRemoteXMLDocument($url) { // THIS FUNCTION IS A CRAP!!!! // I NEED REFACTORY THIS! $handle = FileUtil::OpenRemoteDocument($url); $xmlString = FileUtil::ReadRemoteDocument($handle); $search = array("'&(quot|#34);'i", "'&(amp|#38);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'á'i", "'é'i", "'í'i", "'ó'i", "'ú'i", "'ã'i", "'ç'i", "'&#(\\d+);'e"); // evaluate as php $replace = array("\"", "&", " ", chr(161), chr(162), chr(163), chr(169), "á", "é", "í", "ó", "ú", "ã", "ç", "chr(\\1)"); $xmlString = preg_replace($search, $replace, $xmlString); //$xmlString = tidy_parse_string($xmlString, array('output-xml' => TRUE), 'UTF8'); $xmldoc = XmlUtil::CreateXmlDocumentFromStr($xmlString); return $xmldoc; }