PHP xml_get_current_line_number() Function

Description

The xml_get_current_line_number() function gets the current line number for an XML parser.

Syntax

xml_get_current_line_number(parser)

Parameter

ParameterIs RequiredDescription
parserRequired.XML parser to use

Return

This function returns the current line number on success, or FALSE on failure.

Example

Content for test.xml


<data>
   <missEndTag>
</data>

gets the current line number for an XML parser


<?php/*from  w w  w. j  av  a 2  s  .com*/

$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";
  }
}

xml_parser_free($xmlparser);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions