diff --git a/src/Feed.php b/src/Feed.php index 8fcba58..6a46488 100644 --- a/src/Feed.php +++ b/src/Feed.php @@ -193,7 +193,14 @@ private static function loadXml($url, $user, $pass) throw new FeedException('Cannot load feed.'); } - return new SimpleXMLElement($data, LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOCDATA); + $doc = new DOMDocument(); + $doc->loadXML($data, LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOCDATA); + + if ($doc->documentElement !== NULL) { + return new SimpleXMLElement($doc->saveXML(), LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOCDATA); + } else { + return new SimpleXMLElement('', LIBXML_NOWARNING | LIBXML_NOERROR); + } } @@ -218,6 +225,7 @@ private static function httpRequest($url, $user, $pass) curl_setopt($curl, CURLOPT_TIMEOUT, 20); curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // no echo, just return result + curl_setopt($curl, CURLOPT_USERAGENT, ''); if (!ini_get('open_basedir')) { curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // sometime is useful :) }