Symbian3/PDK/Source/GUID-C5C30218-311C-58D9-A990-3F95642F7517.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-C5C30218-311C-58D9-A990-3F95642F7517" xml:lang="en"><title>Parsing
       
    13 XML DOM</title><shortdesc>This topic explains how to build a DOM tree by parsing an XML file. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    14 <prereq><p>Before you start, you must: </p> <ul>
       
    15 <li id="GUID-B39FCCC0-8791-5234-977A-868616FF4A46"><p>understand the concept
       
    16 of <xref href="http://www.w3.org/DOM/" scope="external">Document Object Model
       
    17 (DOM)</xref>  </p> </li>
       
    18 <li id="GUID-5FEE15C3-9808-5B50-B19B-52C62CC10E46"><p>understand the architecture
       
    19 and classes of the <xref href="GUID-5ACFA8E4-3C4B-5851-A43E-9FA72D0B8403.dita">XML
       
    20 DOM Engine</xref> component </p> </li>
       
    21 <li id="GUID-462DFB7D-1E1D-54C1-A63B-8CE73A8775B5"><p>prepare an XML file
       
    22 containing valid XML data </p> </li>
       
    23 </ul> </prereq>
       
    24 <steps id="GUID-3D797BCC-4D06-5275-9B4F-CAB51649E6D1">
       
    25 <step id="GUID-3DF73431-C215-59FD-9AE7-B4C8FDB98A1C"><cmd/>
       
    26 <info>Call the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>XmlEnginePushL()</apiname></xref> method to
       
    27 put parser resources on the clean-up stack. </info>
       
    28 <stepxmp><codeblock id="GUID-975C0070-DD3D-58CE-908F-687659F45F76" xml:space="preserve">
       
    29 XmlEnginePushL();
       
    30 </codeblock> </stepxmp>
       
    31 </step>
       
    32 <step id="GUID-63B2D6CC-5B11-5466-BD05-837F18D0A810"><cmd>Initialise your
       
    33 instance of the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDOMImplementation</apiname></xref> class
       
    34 by calling its <codeph>OpenL()</codeph> method. </cmd>
       
    35 <stepxmp><codeblock id="GUID-F750DC25-5702-5424-AF2F-5C5D229AB296" xml:space="preserve">
       
    36 RXMlEngDOMImplementation impl;
       
    37 impl.OpenL();
       
    38 </codeblock> </stepxmp>
       
    39 <info>The <codeph>RXMlEngDOMImplementation</codeph> instance is the DOM Engine. </info>
       
    40 </step>
       
    41 <step id="GUID-5C57654A-7B78-5E5D-90E1-94CA025B024B"><cmd/>
       
    42 <info>Initialise the DOM parser by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDOMParser::Open()</apiname></xref> method
       
    43 on its instance. </info>
       
    44 <stepxmp><codeblock id="GUID-F29FAB78-BAE3-553C-858A-6E80A76F754D" xml:space="preserve">
       
    45 RXmlEngDOMParser parser;
       
    46 parser.Open( impl );
       
    47 </codeblock> </stepxmp>
       
    48 <info>You can also have several parsers registered on a DOM Engine instance. </info>
       
    49 </step>
       
    50 <step id="GUID-70BA1E03-92D4-5A3A-9079-A00236D30923"><cmd/>
       
    51 <info>Parse the specified XML file by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDOMParser::ParseFileL()</apiname></xref> method. </info>
       
    52 <stepxmp><codeblock id="GUID-3E26315C-F901-5350-9936-11A6045E7FE7" xml:space="preserve">
       
    53 RXmlDocument myDoc = parser.ParseFileL( "tutorial.xml" );
       
    54 </codeblock> </stepxmp>
       
    55 <info>The <codeph>myDoc</codeph> object is a DOM tree containing the data
       
    56 from the XML file. </info>
       
    57 </step>
       
    58 <step id="GUID-97FC75A5-A4EA-55DC-841B-745E391E2C90"><cmd/>
       
    59 <info>Use the created DOM tree. </info>
       
    60 <info>For example, refer to the <xref href="GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita">Searching
       
    61 a DOM Tree using XPath</xref> to search for specific elements or attributes
       
    62 in the DOM tree. </info>
       
    63 </step>
       
    64 <step id="GUID-9935393A-1359-5708-A9F3-B779F2E2B418"><cmd/>
       
    65 <info>Free your resources as necessary. </info>
       
    66 <substeps id="GUID-CB3D86A2-561D-5281-9DA4-AA8C70A0F498">
       
    67 <substep id="GUID-6D1DC97D-5068-5FCD-AD69-510778348899"><cmd>Close the parser
       
    68 and the engine by calling their <codeph>Close()</codeph> functions. </cmd>
       
    69 <stepxmp><codeblock id="GUID-53680EE0-8291-5C9A-9A7A-04437B1A0836" xml:space="preserve">
       
    70 parser.Close();
       
    71 impl.Close();
       
    72 </codeblock> </stepxmp>
       
    73 </substep>
       
    74 <substep id="GUID-1C28D8BE-D03B-5D9B-BCC7-355FB2A6A93C"><cmd/>
       
    75 <info>Close the XML library by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>XmlPopAndClose()</apiname></xref> method.
       
    76 This method also removes the serialisation resources from the clean-up stack. </info>
       
    77 </substep>
       
    78 <substep id="GUID-BCD8662A-7C1E-5239-87C9-E3917D79C326"><cmd/>
       
    79 <info>Perform any other clean-up operations. </info>
       
    80 </substep>
       
    81 </substeps>
       
    82 </step>
       
    83 </steps>
       
    84 </taskbody><related-links>
       
    85 <link href="GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita"><linktext>Searching
       
    86 a DOM Tree using XPath</linktext></link>
       
    87 <link href="GUID-E20C2C98-A294-551B-99CF-BE1DAA6F597E.dita"><linktext>Serialising
       
    88 XML DOM</linktext></link>
       
    89 </related-links></task>