PHP | DOMNode getLineNo() function Last Updated : 25 Feb, 2020 Comments Improve Suggest changes Like Article Like Report 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 defined in. Below given programs illustrate the DOMNode::getLineNo() function in PHP: Program 1: php <?php // Create a XML variable $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <root> <h1>GeeksforGeeks</h1> </root> XML; // Create a new DOMDocument instance $dom = new DOMDocument; // Load the XML $dom->loadXML($xml); // Print where the line where the 'node' element was defined in echo 'The <node> tag is defined on line ' . $dom->getElementsByTagName('h1')->item(0)->getLineNo(); ?> Output: The tag is defined on line 3 Program 2: php <?php // Create a XML variable $xml = <<<XML <?xml version="1.0" encoding="utf-8"?> <root> <h1>Geeks</h1> <h1>For</h1> <h1>Geeks</h1> </root> XML; // Create a new DOMDocument instance $dom = new DOMDocument(); // Load the XML $dom->loadXML($xml); for ($i = 0; $i < 3; $i++) { // Print where the line where the 'node' element was defined in echo $i . ') The h1 tag is defined on line ' . $dom->getElementsByTagName('h1')->item($i)->getLineNo() . "<br>"; } ?> Output: 0) The h1 tag is defined on line 3 1) The h1 tag is defined on line 4 2) The h1 tag is defined on line 5 Reference: https://www.php.net/manual/en/domnode.getlineno.php Comment More infoAdvertise with us Next Article PHP | DOMNode getLineNo() function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DOMNode isSameNode() Function The DOMNode::isSameNode() function is an inbuilt function in PHP which indicates if two nodes are the same node or not. Syntax: bool DOMNode::isSameNode( DOMNode $node ) Parameters: This function accepts a single parameter $node which holds the node to be compared. Return Value: This function return 2 min read PHP | DOMNode normalize() Function The DOMNode::normalize() function is an inbuilt function in PHP which is used to remove empty text nodes and merge adjacent text nodes in this node and all its children. Syntax: void DOMNode::normalize( void ) Parameters: This function doesnât accept any parameters. Return Value: This function does 2 min read PHP | DOMNode insertBefore() Function The DOMNode::insertBefore() function is an inbuilt function in PHP which is used to insert a new node before a certain another node. Syntax: DOMNode DOMNode::insertBefore( DOMNode $newNode, DOMNode $refNode ) Parameters:This function accepts two parameters as mentioned above and described below: $ne 2 min read PHP | DOMNode hasChildNodes() function The DOMNode::hasChildNodes() function is an inbuilt function in PHP which is used to check if node has children or not. Syntax: bool DOMNode::hasChildNodes( void ) Parameters:This function doesnât accept any parameter. Return Value: This function returns TRUE on success or FALSE on failure. Below gi 1 min read PHP | DOMNamedNodeMap getNamedItemNS() function The DOMNamedNodeMap::getNamedItemNS() function is an inbuilt function in PHP which is used to retrieve a node with a specific local name and namespace URI. This function can be used to get the value of a attribute from a specific namespace. Syntax: DOMNode DOMNamedNodeMap::getNamedItemNS ( string $n 2 min read Like