source: trunk/doc/src/examples/htmlinfo.qdoc@ 1168

Last change on this file since 1168 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
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
58 The work of parsing and the XML and extracting statistics is done in a
59 while loop, and is driven by input from the reader:
60
61 \snippet examples/xml/htmlinfo/main.cpp 1
62
63 If more input is available, the next token from the input file is read
64 and parsed. The program then looks for the specific element types,
65 "title", "a", and "p", and stores information about them.
66
67 When there is no more input, the loop terminates. If an error occurred,
68 information is written to the standard out file via a stream, and the
69 example exits:
70
71 \snippet examples/xml/htmlinfo/main.cpp 2
72
73 If no error occurred, the example prints some statistics from the data
74 gathered in the loop, and then exits.
75*/
Note: See TracBrowser for help on using the repository browser.