PHP | DOMNode lookupPrefix() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The DOMNode::lookupPrefix() function is an inbuilt function in PHP which is used to get the namespace prefix of the node based on the namespace URI.Syntax: string DOMNode::lookupPrefix( string $namespaceURI ) Parameters: This function accepts a single parameter $namespaceURI which holds the namespace URI.Return Value: This function returns the prefix of the namespace.Below examples illustrate the DOMNode::lookupPrefix() function in PHP:Example 1: php <?php // Create a new DOMDocument instance $document = new DOMDocument(); // Load the XML with no namespace $document->loadXML("<?xml version=\"1.0\"?> <div > <h1> GeeksforGeeks </h1> </div> "); // Get the prefix with namespace URI "my_namespace" $prefix = $document->documentElement-> lookupPrefix("my_nsamespace"); echo $prefix; ?> Output: // Empty string as there is no such namespace Example 2: php <?php // Create a new DOMDocument instance $document = new DOMDocument(); // Load the XML with a namespace with prefix x $document->loadXML("<?xml version=\"1.0\"?> <div xmlns:x=\"my_namespace\"> <x:h1 x:style=\"color:red;\"> GeeksforGeeks </x:h1> </div> "); // Get the prefix with namespace URI "my_namespace" $prefix = $document->documentElement-> lookupPrefix('my_namespace'); echo $prefix; ?> Output: x Reference: https://www.php.net/manual/en/domnode.lookupprefix.php Comment More infoAdvertise with us Next Article PHP | DOMNode lookupPrefix() Function gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DOMNode lookupNamespaceUri() Function The DOMNode::lookupNamespaceUri() function is an inbuilt function in PHP which is used to get the namespace URI of the node based on the prefix. Syntax: string DOMNode::lookupNamespaceUri( string $prefix ) Parameters: This function accepts a single parameter $prefix which holds the prefix. Return Va 1 min read PHP | DOMNode isSupported() Function The DOMNode::isSupported() function is an inbuilt function in PHP which is used to check if the asked feature is supported for the specified version. Syntax: bool DOMNode::isSupported( string $feature, string $version ) Parameters: This function accepts two parameters as mentioned above and describe 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 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 | 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 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 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 | DOMNode C14N() Function The DOMNode::C14N() function is an inbuilt function in PHP which is used to convert a node into string. Syntax: string DOMNode::C14N( bool $exclusive, bool $with_comments, array $xpath, array $ns_prefixes ) Parameters: This function accepts four parameters as mentioned above and described below: $ex 2 min read PHP | DOMDocument loadXML() Function The DOMDocument::loadXML() function is an inbuilt function in PHP which is used to load the XML file from a string. Syntax: mixed DOMDocument::loadXML( string $source, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $source: This parameter 2 min read PHP | DOMDocument load() Function The DOMDocument::load() function is an inbuilt function in PHP which is used to load an XML document from a file. Syntax: mixed DOMDocument::load( string $filename, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: This parameter h 1 min read Like