QDomDocument doc("mydocument"); QDomElement root = doc.createElement("root"); doc.appendChild(root); QDomElement child = doc.createElement("child"); root.appendChild(child); QDomNode removed = root.removeChild(child);
QDomNodeList children = root.childNodes(); for(int i=0; iIn this example, we get a list of all the child nodes of the root element using childNodes(). We then iterate through the list, calling removeChild on each child node to remove it from the root element. Package library: Qt.