QDomDocument doc; // ... load or create the document QDomElement root = doc.documentElement(); QDomNodeList children = root.childNodes(); for (int i = 0; i < children.size(); i++) { QDomElement child = children.at(i).toElement(); if (child.tagName() == "remove-me") { root.removeChild(child); } }
QDomElement parent = ...; // get the parent element QDomElement child = ...; // get the child element to remove parent.removeChild(child);This example removes the child element from the specified parent element. The QDomElement class is part of the Qt Core library package, which is included in Qt 4 and Qt 5. To use it, you need to include the