QDomElement root = doc.documentElement(); // assume 'doc' is a QDomDocument object QDomNodeList children = root.childNodes(); for (int i = 0; i < children.size(); i++) { QDomNode child = children.at(i); // do something with child node }
QDomNodeList elements = doc.elementsByTagName("person"); for (int i = 0; i < elements.size(); i++) { QDomElement el = elements.at(i).toElement(); // do something with 'person' element }In this example, we use the `elementsByTagName()` method to retrieve all nodes in the document that have the tag name "person". We then loop through the element nodes and perform some action with each matching node. The QDomNodeList class is part of the Qt Core module.