QDomDocument doc; doc.setContent(""); QDomElement root = doc.documentElement(); qDebug() << "Root element tag name:" << root.tagName(); The Great Gatsby F. Scott Fitzgerald
QDomDocument doc; doc.setContent("In this example, the same QDomDocument object is used, and the documentElement() function is called to get the root element. This time, the child nodes of the root element are retrieved using childNodes() and printed using a loop. Each child node is converted to a QDomElement using toElement() before its tag name is printed."); QDomElement root = doc.documentElement(); QDomNodeList children = root.childNodes(); for (int i = 0; i < children.count(); i++) { QDomElement child = children.at(i).toElement(); qDebug() << "Child element tag name:" << child.tagName(); } The Great Gatsby F. Scott Fitzgerald