PHP | xml_get_current_line_number() Function Last Updated : 07 Aug, 2021 Comments Improve Suggest changes Like Article Like Report The xml_get_current_line_number() function is an inbuilt function in PHP which is used to return the current line number for an XML parser. Syntax: int xml_get_current_line_number( resource $xml_parser ) Parameters: This function accepts a single parameter $xml_parser which is required. It specifies the XML parser which is to be used.Return Value: This function returns the current line number for the specified parser on which it's currently running on success or False on failure. Note: This function is available for PHP 4.0.0 and newer version.These examples may not work on online IDE. So, try to run it on local server or php hosted servers. gfg.xml file: XML <?xml version="1.0" encoding="utf-8"?> <user> <username> user123 </username> <name> firstname lastname </name> <phone> +91-9876543210 </phone> <detail> I am John Doe. Live in Kolkata, India. </detail> </users> PHP <?php // XML file containing mismatch tags $xml_file = 'gfg.xml'; // XML parser initialization $xml_parser = xml_parser_create(); // File opening in read mode $file_pointer = fopen($xml_file, 'r'); // Reading data from the file stream while ($xml_data = fread($file_pointer, 4096)) { // Parse the data chunk if(!xml_parse($xml_parser, $xml_data, feof($file_pointer))) { // Displaying errors die( print "ERROR: " . // Error string xml_error_string(xml_get_error_code($xml_parser)) . "<br/>Error Code: " . // Error code xml_get_error_code($xml_parser) . "<br/>Line: " . // Line number where the error occurred xml_get_current_line_number($xml_parser) . "<br/>Column: " . // Column number where the error occurred xml_get_current_column_number($xml_parser) . "<br/>Byte Index: " . // Byte index where the current byte occurred xml_get_current_byte_index($xml_parser) . "<br/>" ); } } // Free to XML parser xml_parser_free($xml_parser); ?> Output: ERROR: Mismatched tag Error Code: 76 Line: 7 Column: 13 Byte Index: 208 geeks.xml file: XML <?xml version="1.0 encoding="utf-8"?> <user> <username> user123 </username> <name> firstname lastname </name> <phone> +91-9876543210 </phone> <detail> I am John Doe. Live in Kolkata, India. </detail> </user> Program 2: PHP <?php // XML file containing mismatch tags $xml_file = 'geeks.xml'; // XML parser initialization $xml_parser = xml_parser_create(); // File opening in read mode $file_pointer = fopen($xml_file, 'r'); // Reading data from the file stream while ($xml_data = fread($file_pointer, 4096)) { // Parse the data chunk if(!xml_parse($xml_parser, $xml_data, feof($file_pointer))) { // Displaying errors die( print "ERROR: " . // Error string xml_error_string(xml_get_error_code($xml_parser)) . "<br/>Error Code: " . // Error code xml_get_error_code($xml_parser) . "<br/>Line: " . // Line number where the error occurred xml_get_current_line_number($xml_parser) . "<br/>Column: " . // Column number where the error occurred xml_get_current_column_number($xml_parser) . "<br/>Byte Index: " . // Byte index where the current byte occurred xml_get_current_byte_index($xml_parser) . "<br/>" ); } } // Free to XML parser xml_parser_free($xml_parser); ?> Output: ERROR: String not closed expecting " or ' Error Code: 34 Line: 1 Column: 36 Byte Index: 37 Reference: https://www.php.net/manual/en/function.xml-get-current-line-number.php Comment More infoAdvertise with us Next Article PHP | xml_get_current_line_number() Function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-XML Similar Reads PHP | xml_get_current_column_number() Function The xml_get_current_column_number() function is an inbuilt function in PHP which is used to get the current column number of given parser. Syntax:Â int xml_get_current_column_number( resource $xml_parser ) Parameters: This function accepts single parameter $xml_parser which is required. This paramet 3 min read PHP | xml_parser_get_option() Function Pre-requisite: XML Basics The xml_parser_get_option() function is an inbuilt function in PHP which retrieves the options from an XML parser. Syntax: mixed xml_parser_get_option( resource $parser, int $specified_option ) Parameters: This function accepts two parameters as mentioned above and describe 2 min read PHP | xml_parser_create() Function The xml_parser_create() function is an inbuilt function in PHP which is used to create an XML parser. Syntax:Â resource xml_parser_create( string $encoding ) Parameters: This function accepts single parameter $encoding which is optional. It specifies the character encoding:Â Â for input/output in PHP 3 min read PHP | xml_get_error_code() Function The xml_get_error_code() function is an inbuilt function in PHP which is used to return the error code generated by XML parser. Syntax:Â int xml_get_error_code( resource $xml_parser ) Parameters: This function accepts single parameter $xml_parser which is required. It specifies the XML parser which 3 min read PHP | DOMNode getLineNo() function The DOMNode::getLineNo() function is an inbuilt function in PHP which is used to get the line number for where the node is defined. Syntax: DOMNode DOMNode::getLineNo( void ) Parameters:This function doesnât accept any parameter. Return Value: This function returns the line number where the node was 2 min read PHP | xml_parser_free() Function Pre-requisite: XML BasicsThe xml_parser_free() function is an inbuilt function in PHP which is used to free the XML parser. Syntax:Â Â bool xml_parser_free( resource $parser ) Parameters: This function accepts single parameter $parser which is required. It specifies the reference of XML parser to fre 3 min read PHP ob_get_length() Function The ob_get_length() function is an inbuilt function in PHP that is used to get the length of the current output buffer. The output buffer length is the number of bytes in the buffer. Syntax: ob_get_length(): int|falseParameters: This function does not accept any parameter. Return Values: The ob_get_ 2 min read PHP | SimpleXMLIterator current() Function The SimpleXMLIterator::current() function is an inbuilt function in PHP which is used to return the current element as a SimpleXMLIterator object or NULL. Syntax: mixed SimpleXMLIterator::current( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns t 1 min read PHP | SplFileObject current( ) Function The SplFileObject::current() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get current line of file. Syntax: string SplFileObject::current( void ) Parameters: This function does not accept any parameter. Return values: Returns current line of the file. Below P 2 min read PHP | DOMDocument getElementsByTagnameNS() Function The DOMDocument::getElementsByTagNameNS() function is an inbuilt function in PHP which is used to search for all elements with given tag name in specified namespace. Syntax: DOMNodeList DOMDocument::getElementsByTagNameNS( string $namespaceURI, string $localName ) Parameters: This function accepts t 2 min read Like