xml get current column number in PHP

In this article I will explain how the xml_get_current_column_number() function can be used in PHP.
  • 2357

xml_get_current_column_number() function in PHP

  • The xml_get_current_column_number() function is used to get the current column number for an XML parser.
  • The xml_get_current_column_number() function returns the current column number on success.
  • The xml_get_current_column_number() function returns FALSE on failure.

Syntax

xml_get_current_column_number(parser)

Parameter

  • parser parser is required parameter. it is specify for XML parser to use.
Example

The following example show to how the xml_get_current_column_number() function can be used in PHP.

<html>

<body>

<h3 style="color: blue;">xml_get_current_column_number() function example in PHP</h3>

    <?php

    $file = "xmltest.xml";

    $xml_parser = xml_parser_create();

    $fp = @fopen($file,'r');

    while ($data = fread($fp,4096))

    {

    if (!xml_parse($xml_parser,$data,feof($fp)))

    {

    die( print "ERROR Name in XML Parser: "

    . xml_error_string(xml_get_error_code($xml_parser))

    . "<br />"

    . "Current Line No. of XML Parser: "

    . xml_get_current_line_number($xml_parser)

    . "<br />"

    . "Current Column No. of XML Parser: "

    . xml_get_current_column_number($xml_parser)

    . "<br />");

    }

    }

    xml_parser_free($xml_parser);

    ?>

</body>

</html>

 

Output

xml-get-current-column-number-php.gif
You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
© 2020 DotNetHeaven. All rights reserved.