PHP xml_get_error_code() Function
In this chapter you will learn:
- Description for PHP xml_get_error_code() Function
- Syntax for PHP xml_get_error_code() Function
- Parameter for PHP xml_get_error_code() Function
- Return for PHP xml_get_error_code() Function
- Example - gets the XML parser error code
Description
The xml_get_error_code() function gets the XML parser error code.
Syntax
xml_get_error_code(parser)
Parameter
Parameter | Is Required | Description |
---|---|---|
parser | Required. | XML parser to use |
Return
This function returns the error code on success, or FALSE on failure.
Example
Content for test.xml
<data>
<missEndTag>
</data>
Get the XML parser error code
<?php/* java2s. c om*/
$xmlparser = xml_parser_create();
$fp = fopen('test.xml', 'r');
while ($xmldata = fread($fp, 1024)){
if (!xml_parse($xmlparser,$xmldata,feof($fp))){
print "ERROR: ";
print xml_error_string(xml_get_error_code($xmlparser));
print "\n";
print "Line: ";
print xml_get_current_line_number($xmlparser);
print "\n";
print "Column: ";
print xml_get_current_column_number($xmlparser);
print "\n";
}
}
xml_parser_free($xmlparser);
?>
Next chapter...
What you will learn in the next chapter:
- Description for PHP xml_parse() Function
- Syntax for PHP xml_parse() Function
- Parameter for PHP xml_parse() Function
- Return for PHP xml_parse() Function
- XML File used in later example
- Example - Parse xml data
- Example - Action methods for start and end tags
Home » PHP Tutorial » PHP XML Functions