ID: 37617 Updated by: [EMAIL PROTECTED] Reported By: webmaster at freshtraxxx dot com -Status: Open +Status: Bogus Bug Type: XML related Operating System: Windows XP Home PHP Version: 5CVS-2006-05-28 (snap) New Comment:
If libxml fails to parse your file PHP can't do anything about it. Not PHP problem. Previous Comments: ------------------------------------------------------------------------ [2006-05-28 18:12:06] webmaster at freshtraxxx dot com Description: ------------ Error results when trying to parse an rdf news feed with the listed doctype element. Although this is similar to previous bugs it still seems to be happening with the latest version. I have a workaround that stripps out the offending lines until this is fixed: preg_match("/<rdf:RDF(.*?)>(.*?)<\/rdf:RDF>/s",$output,$match); if($match[0]) { $output = $match[0]; } Reproduce code: --------------- // functions "startElement", "endElement" and "characterData" stripped out for clarity $output = <<<EOF <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"> %HTMLlat1; ]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> </rdf:RDF> EOF; $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); if (!xml_parse($xml_parser, $output, true)) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } xml_parser_free($xml_parser); Expected result: ---------------- Expected no output in above script as the handler functions only output cdata from within the rdf elements Actual result: -------------- XML error: Undeclared entity error at line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37617&edit=1