QDomElement root = doc.documentElement(); QDomNode node = root.firstChild(); while (!node.isNull()) { QDomNode next = node.nextSibling(); // do something with node and next node = next; }
QDomElement element = doc.firstChildElement("root"); QDomNode node = element.firstChild(); if (node.nextSibling().nodeName() == "second") { // do something with second node }In this example, the code checks if the next sibling of the first child element of the "root" node has a specific node name, "second". If so, it performs some operation on that node. Package library: Qt Core module, part of the Qt library.