PHP | DOMNode removeChild() Function Last Updated : 02 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The DOMNode::removeChild() function is an inbuilt function in PHP which is used remove child from list of children. Syntax: DOMNode DOMNode::removeChild( DOMNode $oldnode ) Parameters: This function accepts a single parameter $oldnode which holds the child to remove. Return Value: This function returns the removed child on success. Exceptions: This function throws DOM_NO_MODIFICATION_ALLOWED_ERR, if the node is readonly and DOM_NOT_FOUND, if $oldnode is not a child of this node. Below examples illustrate the DOMNode::removeChild() function in PHP: Example 1: php <?php // Create a new DOMDocument instance $document = new DOMDocument(); // Create a div element $element = $document-> appendChild(new DOMElement('div')); // Create a text Node $text1 = $document-> createTextNode('GeeksforGeeks'); // Append the nodes $element->appendChild($text1); // Remove the child $element->removeChild($text1); // Render the XML echo $document->saveXML(); ?> Output: Press Ctrl+U to see the XML Example 2: php <?php // Create a new DOMDocument instance $document = new DOMDocument(); // Create a h1 element $element = $document-> appendChild(new DOMElement('h1')); // Create the text Node $text1 = $document-> createTextNode('GeeksforGeeks'); $text2 = $document-> createTextNode('Text to be removed'); // Append the nodes $element->appendChild($text1); $element->appendChild($text2); // Remove the child $element->removeChild($text2); // Render the output echo $document->saveXML(); ?> Output: Reference: https://www.php.net/manual/en/domnode.removechild.php Comment More infoAdvertise with us Next Article PHP | DOMNode removeChild() Function gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DsDeque remove() Function The Ds\Deque::remove() function is an inbuilt function in PHP which is used to remove and return the index value. Syntax: public Ds\Deque::remove( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index of Deque for which the element is to be returned and rem 2 min read PHP | DsSequence remove() Function The Ds\Sequence::remove() function is an inbuilt function in PHP which is used to remove and return a value by index. Syntax: mixed abstract public Ds\Sequence::remove ( int $index ) Parameters: This function accepts a single parameter $index which holds the index of value to remove. Return value: T 1 min read PHP | DsVector remove() Function The Ds\Vector::remove() function is an inbuilt function in PHP that is used to remove an element from the Vector at the specified ï¼index argument and returns the removed element. Syntax: mixed public Ds\Vector::remove( $index ) Â Parameters: This function does not accept any parameter. Â Return Value: 1 min read PHP DOMDocument saveHTML() Function The DOMDocument::saveHTML() function is an inbuilt function in PHP that is used to create an HTML document from the DOM representation. This function is used after building the dom document from scratch. Syntax: string DOMDocument::saveHTML( DOMNode $node = NULL ) Parameters: This function accepts s 2 min read PHP | DOMElement removeAttribute() Function The DOMElement::removeAttribute() function is an inbuilt function in PHP which is used to remove a attribute with specific name from the element. Syntax: bool DOMElement::removeAttribute( string $name ) Parameters: This function accepts a single parameter $name which holds the name of the attribute. 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 saveHTMLFile() Function The DOMDocument::saveHTMLFile() function is an inbuilt function in PHP that is used to create an HTML document from the DOM representation. This function is used after creating the dom document. Syntax: int DOMDocument::saveHTMLFile( string $filename ) Parameters: This function accepts a single para 2 min read PHP | DOMElement removeAttributeNode() Function The DOMElement::removeAttributeNode() function is an inbuilt function in PHP which is used to remove attribute from element. Syntax: bool DOMElement::removeAttributeNode( DOMAttr $oldnode ) Parameters: This function accepts a single parameter $oldnode which holds the attribute that to be removed. Re 2 min read PHP | DOMDocument saveXML() Function The DOMDocument::saveXML() function is an inbuilt function in PHP which is used to create an XML document from the DOM representation. This function is used after building a new dom document from scratch. Syntax: string DOMDocument::saveXML( DOMNode $node, int $options = 0 ) Parameters: This functio 2 min read Like