Fonkashin PHP xml_get_current_line_number()

Kirkirin da koyarwa

Fonkashin xml_get_current_line_number() yana girmo kanamun daki yanki na yankin aiki.

Yarancin

xml_get_current_line_number()parser)
Parameter Description
parser Required. Specifies the XML parser to use.

Description

If parser Parameter does not point to a valid parser, the function will return FALSE otherwise it will return the current line number in the specified parser's cache.

Example

<?php
// Invalid xml file
$xmlfile = 'test.xml';
$xmlparser = xml_parser_create();
// Open 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);
?>

Output:

ERROR: Mismatched tag
Line: 8
Column: 61