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 G 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 Like