PHP xml_get_current_byte_index() Function
In this chapter you will learn:
- Description for PHP xml_get_current_byte_index() Function
- Syntax for PHP xml_get_current_byte_index() Function
- Parameter for PHP xml_get_current_byte_index() Function
- Return for PHP xml_get_current_byte_index() Function
- Example - gets the byte index for an XML parser
Description
The xml_get_current_byte_index() function gets the byte index for an XML parser.
Syntax
PHP xml_get_current_byte_index() Function has the following syntax.
xml_get_current_byte_index(parser)
Parameter
Parameter | Is Required | Description |
---|---|---|
parser | Required. | XML parser to use |
Return
This function returns the current byte index on success, or FALSE on failure.
Example
Content for test.xml
<data>
<missEndTag>
</data>
<?php//j a v a 2s . c o m
$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";
print "Byte Index: ";
print xml_get_current_byte_index($xmlparser);
print "\n";
}
}
xml_parser_free($xmlparser);
?>
Next chapter...
What you will learn in the next chapter:
- Description for PHP xml_get_current_column_number() Function
- Syntax for PHP xml_get_current_column_number() Function
- Parameter for PHP xml_get_current_column_number() Function
- Return for PHP xml_get_current_column_number() Function
- Example - gets the current column number for an XML parser
Home » PHP Tutorial » PHP XML Functions