Funkcja PHP xml_get_current_column_number()
❮ Dokumentacja parsera PHP XML
Przykład
W przypadku błędu zwróć opis błędu parsera XML, numer wiersza i numer kolumny:
<?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>");
}
}
xml_parser_free($xmlparser);
?>
Wynikiem powyższego kodu może być:
ERROR: Mismatched tag
Line: 5
Column: 41
Definicja i użycie
Funkcja xml_get_current_column_number() zwraca bieżący numer kolumny dla parsera XML.
Składnia
xml_get_current_column_number(parser)
Wartości parametrów
Parameter | Description |
---|---|
parser | Required. Specifies the XML parser to use |
Szczegóły techniczne
Wartość zwrotu: | Aktualny numer kolumny w przypadku powodzenia. FAŁSZ w przypadku niepowodzenia |
---|---|
Wersja PHP: | 4.0+ |
❮ Dokumentacja parsera PHP XML