PHP xml_error_string() º¯Êý
¶¨ÒåºÍÓ÷¨
xml_error_string() º¯Êý»ñÈ¡ XML ½âÎöÆ÷µÄ´íÎóÃèÊö¡£
Óï·¨
xml_error_string(errorcode)
²ÎÊý | ÃèÊö |
---|---|
errorcode | ±ØÐè¡£¹æ¶¨ÒªÊ¹ÓõĴíÎó´úÂë¡£¸Ã´íÎóÂëÊÇ xml_get_error_code() º¯ÊýµÄ·µ»ØÖµ¡£ |
˵Ã÷
·µ»ØÓë errorcode ÃèÊöµÄ´íÎó´úÂë²ÎÊý¶ÔÓ¦µÄÎı¾ÃèÊö×Ö·û´®£¬ÈôûÓÐÓëÖ®¶ÔÓ¦µÄÃèÊö£¬Ôò·µ»Ø false¡£
Àý×Ó
<?php
//ÎÞЧµÄ xml Îļþ
$xmlfile = 'test.xml';
$xmlparser = xml_parser_create();
// open a file and read data
$fp = fopen($xmlfile, 'r');
while ($xmldata = fread($fp, 4096))
{
// parse the data chunk
if (!xml_parse($xmlparser,$xmldata,feof($fp)))
{
die( print "ERROR: "
. xml_error_string(xml_get_error_code($xmlparser))
. "<br />"
. "Line: "
. xml_get_current_line_number($xmlparser)
. "<br />"
. "Column: "
. xml_get_current_column_number($xmlparser)
. "<br />");
}
}
xml_parser_free($xmlparser);
?>
Êä³ö£º
ERROR: Mismatched tag Line: 8 Column: 51