Symbian3/SDK/Source/GUID-5012D63B-4353-5616-BBFB-DB04DAF71679.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-5012D63B-4353-5616-BBFB-DB04DAF71679" xml:lang="en"><title>XmlExample: Using the XML framework to parse an XML file</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-7860D226-83AD-501E-9431-6A61A9AC2996"><title>Download</title> <p>Click on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-3eef58b5-bcd4-4f1e-a864-71273651c3bb.zip" scope="external">XmlExample.zip</xref></p><p>Click:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-3eef58b5-bcd4-4f1e-a864-71273651c3bb.html" scope="peer">browse</xref> to view the example code. </p> </section>
<section id="GUID-8E9C9A4C-288F-4B0B-B880-853895EA252A"><title>Introduction</title> <p>This example application demonstrates
the usage of the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>XML</apiname></xref> framework API to parse XML
and WBXML files. </p> <p>The overview contains the following sections: </p> <ul>
<li id="GUID-01C9B600-A55E-55D8-AA35-057464345A45"><p> <xref href="GUID-5012D63B-4353-5616-BBFB-DB04DAF71679.dita#GUID-5012D63B-4353-5616-BBFB-DB04DAF71679/GUID-3A5027A1-BEE9-5EB4-8670-7E729CF9260F">Description</xref>  </p> </li>
<li id="GUID-656E68A4-BAF3-505B-AC9A-96C6A9107E1B"><p> <xref href="GUID-5012D63B-4353-5616-BBFB-DB04DAF71679.dita#GUID-5012D63B-4353-5616-BBFB-DB04DAF71679/GUID-5dfd0234-44cf-4252-a980-5b73aaa61e35">Class summary</xref>  </p> </li>
<li id="GUID-F8CEA6F8-D4AB-5E32-9EC1-9FACED6F34B5"><p> <xref href="GUID-5012D63B-4353-5616-BBFB-DB04DAF71679.dita#GUID-5012D63B-4353-5616-BBFB-DB04DAF71679/GUID-E9F975CA-A59F-5484-83FD-7F17F0A03807">Build</xref>  </p> </li>
</ul> </section>
<section id="GUID-3A5027A1-BEE9-5EB4-8670-7E729CF9260F"><title>Description</title> <p>The example application demonstrates, how to use the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita"><apiname>Xml</apiname></xref> framework to parse XML and WBXML files. It takes a
valid XML file with a DTD (Document Type Declaration) definining its
structure, and a WBXML (WAP Binary XML format) file as input. You
can generate a WBXML file from an XML file using any freeware converters.
The application's <filepath>bld.inf</filepath> file specifies the
target path to which all the three files (XML, DTD, WBXML) need to
be exported. </p> <p>The application implements all the pure virtual
functions of the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-25E466A4-0578-3BED-A56D-4E0906313788"><apiname>Xml::MContentHandler</apiname></xref> class, which
is a client interface to the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita"><apiname>Xml</apiname></xref> framework. These
functions inform the client application about the XML element being
parsed, its content, parser errors if any and so on. </p> <p>The XML
and WBXML files are parsed using an object of the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE"><apiname>Xml::CParser</apiname></xref> class. The parser object is configured to report namespace mappings
to the client application, using the function <xref href="GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE.dita#GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE/GUID-5F2688CC-16B3-3F0D-B6CA-CE59FE7939BD"><apiname>Xml::CParser::EnableFeature()</apiname></xref>. </p> <p>The application first opens a file session using <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita"><apiname>RFs</apiname></xref> to read the XML and WBXML files. Then, the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-CC810749-2F0D-3CC0-911D-EE12BB934867"><apiname>Xml::ParseL()</apiname></xref> function is called to start parsing the files.
The application parses the XML file followed by the WBXML file. While
these files are being parsed, status messages are printed to the console
by the callback functions as and when they are invoked. </p> <p>For
demonstration purposes, the XML file is parsed twice, once by the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE"><apiname>Xml::CParser</apiname></xref> object created using the MIME type and again
by the <codeph>CParser</codeph> object created using match data criteria.
The match data criteria are specified using an object of the <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-AEFF2DB4-FBC2-36EE-A4CE-7EBBD4AF004E"><apiname>Xml::CMatchData</apiname></xref> class, which is passed to the <xref href="GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE.dita#GUID-EE37CB28-DAB4-30A9-B46E-8AE4664B28DE/GUID-9E9D8DBA-A396-3F62-8B59-C4556FD5A80E"><apiname>Xml::CParser::NewLC()</apiname></xref> function while creating the parser
object. This will return a <codeph>CParser</codeph> object that matches
the specified MIME type, variant and so on. </p> </section>
<section id="GUID-5DFD0234-44CF-4252-A980-5B73AAA61E35"><title>Class
summary</title><p> <xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-25E466A4-0578-3BED-A56D-4E0906313788"><apiname>Xml::MContentHandler </apiname></xref><xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-88087934-B84B-39DD-907F-71328D684035"><apiname>Xml::RDocumentParameters </apiname></xref><xref href="GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473.dita#GUID-54A442BD-FCF1-31D3-BEF7-598C1820F473/GUID-A8A238B9-48A5-3729-9BAE-0287EE6295FA"><apiname>Xml::RAttributeArray </apiname></xref><xref href="GUID-DEFFFAAD-662A-34E9-8955-759F37BDC9AB.dita#GUID-DEFFFAAD-662A-34E9-8955-759F37BDC9AB/GUID-9A8E865C-FDAC-3923-83A9-5A8680AEE1EE"><apiname>Xml::CParserXml::CMatchData </apiname></xref> </p></section>
<section id="GUID-E9F975CA-A59F-5484-83FD-7F17F0A03807"><title>Build</title> <p>The Symbian platform build process describes how to build an
application. </p> <p>The <codeph>XmlExample</codeph> builds an executable called <filepath>xmlexample.exe</filepath> in
the standard location (<filepath>\epoc32\release\winscw\&lt;build_variant&gt;</filepath> for CodeWarrior). After launching the executable, depending on the
emulator you are using, you may need to task away from the application
launcher/shell screen to view the console. </p> </section>
</conbody></concept>