public static function get_parser($data, $url = false, $debug = false) { libxml_use_internal_errors(true); $data = trim($data); $xml = @simplexml_load_string($data, null, LIBXML_DTDLOAD); if (!$xml) { if ($debug) { echo "******** RSS PARSING ERROR: XML could not be loaded ********\n"; foreach (libxml_get_errors() as $error) { printf("Error %d on line %d, column %d, level %d\n %s", $error->code, $error->line, $error->column, $error->level, $error->message); } } return false; } if ($xml->getName() == "feed") { $rss = new Atom($xml, $debug); $rss->set_url($url); return $rss; } if ($xml->getName() == "rss") { if ($xml['version'] == "2.0") { $rss = new Rss20($xml, $debug); $rss->set_url($url); return $rss; } } if ($debug) { printf("******** RSS PARSING ERROR: %s/%s ********\n", $xml->getName(), $xml['version']); } return false; }