您现在的位置是:首页 > PHP函数

李清波 2015-10-01 PHP函数 1941 复制当前网址

xml_error_string



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


文章来源:http://liqingbo.com/blog-894.html

上一篇:xml_get_current_byte_index

下一篇:utf8_encode

评论