Funkce PHP xml_get_current_byte_index().
❮ Referenční příručka PHP XML Parser
Příklad
V případě chyby vraťte popis chyby analyzátoru XML, číslo řádku, číslo sloupce a index bajtu:
<?php
// Invalid xml file
$xmlfile = 'test.xml';
$xmlparser = xml_parser_create();
// Open the 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>Byte Index: "
. xml_get_current_byte_index($xmlparser)
. "<br>");
}
}
xml_parser_free($xmlparser);
?>
Výstup výše uvedeného kódu může být:
ERROR: Mismatched tag
Line: 5
Column: 41
Byte Index: 72
Definice a použití
Funkce xml_get_current_byte_index() vrací bajtový index pro analyzátor XML.
Syntax
xml_get_current_byte_index(parser)
Hodnoty parametrů
Parameter | Description |
---|---|
parser | Required. Specifies the XML parser to use |
Technické údaje
Návratová hodnota: | Aktuální bajtový index při úspěchu. NEPRAVDA při selhání |
---|---|
Verze PHP: | 4,0+ |
❮ Referenční příručka PHP XML Parser