PHP中的XML_ERROR_STRING()函数

  • XML_ERROR_STRING()函数用于获取XML解析器错误描述。
  • XML_ERROR_STRING()函数返回成功的错误描述。
  • XML_ERROR_STRING()函数返回错误时失败。

语法

xml_error_string(errorcode)

参数

  • ErrorCode ErrorCode是必需参数。它是指定要使用的错误代码。错误代码是XML_GET_ERROR_CODE()函数的返回值。
PHP中的xml_error_string函数

PHP中的XML_ERROR_STRING()函数示例

<?php

$file = "xmltest.xml";
$xml_parser = xml_parser_create();
$fp = @fopen($file,'r');
while ($data = fread($fp,4096))

{
	if (!xml_parse($xml_parser,$data,feof($fp)))
	{
	die( print "ERROR: "

	. xml_error_string(xml_get_error_code($xml_parser))
	. "<br />"
	. "Line: "
	. xml_get_current_line_number($xml_parser)

	. "<br />"
	. "Column: "
	. xml_get_current_column_number($xml_parser)
	. "<br />");

	}
}
xml_parser_free($xml_parser);
?>
日期:2020-06-02 22:15:38 来源:oir作者:oir