$html = '
$xml = ''; $dom = new DOMDocument(); $dom->loadXML($xml); $root = $dom->getElementsByTagName('root')->item(0); $element2 = $root->getElementsByTagName('element2')->item(0); $root->removeChild($element2); echo $dom->saveXML(); Value 1 Value 2 Value 3
The removeChild function is a method of the DOMDocument class, which is part of the DOM extension in PHP. This extension is included in the standard PHP distribution, so no additional package or library is required.Value 1 Value 3