PHP xml_get_current_column_number() function

Definition and Usage

The xml_get_current_column_number() function retrieves the current column number of the XML parser.

syntax

xml_get_current_byte_index(parser)
parameters description
parser necessary. Specify the XML parser to be used.

indication

if parser parameter does not point to a valid parser, the function will return false. Otherwise, it will return the line number of the specified parser (by the function xml_get_current_line_number() the current column number of the given)

Example

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