function sxe($url) { $xml = file_get_contents($url); foreach ($http_response_header as $header) { if (preg_match('#^Content-Type: text/xml; charset=(.*)#i', $header, $m)) { switch (strtolower($m[1])) { case 'utf-8': // do nothing break; case 'iso-8859-1': $xml = utf8_encode($xml); break; default: $xml = iconv($m[1], 'utf-8', $xml); } break; } } return simplexml_load_string($xml); }