1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \example xml/htmlinfo
|
---|
30 | \title XML HTML Info Example
|
---|
31 |
|
---|
32 | The XML HTML Info example provides a simple command line utility that
|
---|
33 | scans the current directory for HTML files and prints statistics about
|
---|
34 | them to standard out.
|
---|
35 |
|
---|
36 | \note Standard out is redirected on some platforms. On Symbian using Open
|
---|
37 | C \c stdout is by default directed to the console window, but this window
|
---|
38 | may not always be visible. To redirect to a file instead, locate the \c
|
---|
39 | c:\\system\\data\\config.ini file (on either the emulator or the device)
|
---|
40 | and change \c STDOUT to point to \c MEDIA4. This will redirect the console
|
---|
41 | to \c c:\\system\\data\\out.txt.
|
---|
42 |
|
---|
43 | The files are parsed using a QXmlStreamReader object. If the file does
|
---|
44 | not contain a well-formed XML document, a description of the error is
|
---|
45 | printed to the standard error console.
|
---|
46 |
|
---|
47 | \section1 Basic Operation
|
---|
48 |
|
---|
49 | The main function of the example uses QDir to access files in the current
|
---|
50 | directory that match either "*.htm" or "*.html". For each file found,
|
---|
51 | the \c parseHtmlFile() function is called.
|
---|
52 |
|
---|
53 | Reading XML is handled by an instance of the QXmlStreamReader class, which
|
---|
54 | operates on the input file object:
|
---|
55 |
|
---|
56 | \snippet examples/xml/htmlinfo/main.cpp 0
|
---|
57 |
|
---|
|
---|