DOMNode::removeChild

Removes child from list of children

&reftitle.description; public ``DOMNode``false```DOMNode::removeChild` `DOMNode` `child`

This functions removes a child from a list of children.

&reftitle.parameters;

`child`

- The removed child.

&reftitle.returnvalues;

If the child could be removed the function returns the old child or &false; on error.

&reftitle.errors;

`DOM_NO_MODIFICATION_ALLOWED_ERR`

- Raised if this node is readonly.

`DOM_NOT_FOUND_ERR`

- Raised if `child` is not a child of this node.

&reftitle.examples;

The following example will delete the `chapter` element of our XML document.

### Removing a child

    <?php

    $doc = new DOMDocument;
    $doc->load('book.xml');

    $book = $doc->documentElement;

    // we retrieve the chapter and remove it from the book
    $chapter = $book->getElementsByTagName('chapter')->item(0);
    $oldchapter = $book->removeChild($chapter);

    echo $doc->saveXML();
    ?>

&example.outputs;

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
              "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
    <book id="listing">
     <title>My lists</title>

    </book>

&reftitle.seealso;

- `DOMChildNode::remove`
- `DOMNode::appendChild`
- `DOMNode::replaceChild`