summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp
blob: e115933f43033c615c238e1438bb9fab21d15029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [0]
// file is an open QFile object.
QDomDocument document;
if (document.setContent(&file)) {

    QDomElement documentElement = document.documentElement();
    QString text;
    QDomNode node = documentElement.firstChild();

    while (!node.isNull()) {
        if (node.isText())
            text += node.nodeValue();
        else if (node.hasChildNodes()) {
            // Examine the node's children and read any text found.
            ...
        }
        node = node.nextSibling();
    }
}
//! [0]