xml error string in PHP
In this article I will explain how the xml_error_string() function can be used in PHP.
xml_error_string() function in PHP
- The xml_error_string() function is used to get the XML parser error description.
- The xml_error_string() function returns the error description on success.
- The xml_error_string() function returns FALSE on failure.
Syntax
xml_error_string(errorcode) |
Parameter
- errorcode errorcode is required parameter. it is specify for error code to use. The error code is the return value from the xml_get_error_code() function.
Example
The following example show to how the xml_error_string() function can be used in PHP.
<html>
<body>
<h3 style="color: darkblue;">xml_error_string() function example in PHP</h3>
<?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);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here