ID: 31291 Updated by: [EMAIL PROTECTED] Reported By: adminsun at 126 dot com -Status: Open +Status: Bogus Bug Type: XML related Operating System: WindowsXP PHP Version: 5.0.3 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. . Previous Comments: ------------------------------------------------------------------------ [2004-12-25 09:42:41] adminsun at 126 dot com Description: ------------ This Code in PHP 4 running is ok, But in PHP5 Display "XML error: Invalid character at line 2", Why?? Reproduce code: --------------- function makeTree($XML_FILE = ""){ if(get_magic_quotes_runtime()){ set_magic_quotes_runtime (0); $mq = 1; } $this->parser = xml_parser_create(); xml_set_object($this->parser, &$this); xml_set_element_handler($this->parser, "startElement", "endElement"); xml_set_character_data_handler ( $this->parser, "dataElement"); if($XML_FILE){ if (!($fp = fopen($XML_FILE, "r"))) { die("Could not open XML file"); } } else{ if (!($fp = fopen($this->file, "r"))) { die("Could not open XML file"); } } while ($data = fread($fp, 4096)) { $ffile=xml_parse($this->parser, $data, feof($fp)); if (!$ffile) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser))); } } xml_parser_free($this->parser); if($mq){ set_magic_quotes_runtime (1); } return $this->displayTree(); } // end makeTree() //---------------------------------------------------------------------------------------- function makeTreeText($XML_TEXT = ""){ if(get_magic_quotes_runtime()){ set_magic_quotes_runtime (0); $mq = 1; } $this->parser = xml_parser_create(); xml_set_object($this->parser, &$this); xml_set_element_handler($this->parser, "startElement", "endElement"); xml_set_character_data_handler ( $this->parser, "dataElement"); if($XML_TEXT=="") { die("XML TEXT is empty!"); } $POS=0; $LEN=strlen($XML_TEXT); while ($data = substr($XML_TEXT,$POS, 4096)) { $data=str_replace("\0","/0",$data); $data=str_replace("&","&",$data); $cdata=xml_parse($this->parser, $data, 0); if (!$cdata) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser))); } $POS+=4096; if($POS>=$LEN) break; } xml_parser_free($this->parser); if($mq){ set_magic_quotes_runtime (1); } return $this->displayTree(); } // end makeTree() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31291&edit=1