Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
<?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 task+ −
PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">+ −
<task id="GUID-C5C30218-311C-58D9-A990-3F95642F7517" xml:lang="en"><title>Parsing+ −
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>+ −
<prereq><p>Before you start, you must: </p> <ul>+ −
<li id="GUID-B39FCCC0-8791-5234-977A-868616FF4A46"><p>understand the concept+ −
of <xref href="http://www.w3.org/DOM/" scope="external">Document Object Model+ −
(DOM)</xref> </p> </li>+ −
<li id="GUID-5FEE15C3-9808-5B50-B19B-52C62CC10E46"><p>understand the architecture+ −
and classes of the <xref href="GUID-5ACFA8E4-3C4B-5851-A43E-9FA72D0B8403.dita">XML+ −
DOM Engine</xref> component </p> </li>+ −
<li id="GUID-462DFB7D-1E1D-54C1-A63B-8CE73A8775B5"><p>prepare an XML file+ −
containing valid XML data </p> </li>+ −
</ul> </prereq>+ −
<steps id="GUID-3D797BCC-4D06-5275-9B4F-CAB51649E6D1">+ −
<step id="GUID-3DF73431-C215-59FD-9AE7-B4C8FDB98A1C"><cmd/>+ −
<info>Call the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>XmlEnginePushL()</apiname></xref> method to+ −
put parser resources on the clean-up stack. </info>+ −
<stepxmp><codeblock id="GUID-975C0070-DD3D-58CE-908F-687659F45F76" xml:space="preserve">+ −
XmlEnginePushL();+ −
</codeblock> </stepxmp>+ −
</step>+ −
<step id="GUID-63B2D6CC-5B11-5466-BD05-837F18D0A810"><cmd>Initialise your+ −
instance of the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDOMImplementation</apiname></xref> class+ −
by calling its <codeph>OpenL()</codeph> method. </cmd>+ −
<stepxmp><codeblock id="GUID-F750DC25-5702-5424-AF2F-5C5D229AB296" xml:space="preserve">+ −
RXMlEngDOMImplementation impl;+ −
impl.OpenL();+ −
</codeblock> </stepxmp>+ −
<info>The <codeph>RXMlEngDOMImplementation</codeph> instance is the DOM Engine. </info>+ −
</step>+ −
<step id="GUID-5C57654A-7B78-5E5D-90E1-94CA025B024B"><cmd/>+ −
<info>Initialise the DOM parser by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDOMParser::Open()</apiname></xref> method+ −
on its instance. </info>+ −
<stepxmp><codeblock id="GUID-F29FAB78-BAE3-553C-858A-6E80A76F754D" xml:space="preserve">+ −
RXmlEngDOMParser parser;+ −
parser.Open( impl );+ −
</codeblock> </stepxmp>+ −
<info>You can also have several parsers registered on a DOM Engine instance. </info>+ −
</step>+ −
<step id="GUID-70BA1E03-92D4-5A3A-9079-A00236D30923"><cmd/>+ −
<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>+ −
<stepxmp><codeblock id="GUID-3E26315C-F901-5350-9936-11A6045E7FE7" xml:space="preserve">+ −
RXmlDocument myDoc = parser.ParseFileL( "tutorial.xml" );+ −
</codeblock> </stepxmp>+ −
<info>The <codeph>myDoc</codeph> object is a DOM tree containing the data+ −
from the XML file. </info>+ −
</step>+ −
<step id="GUID-97FC75A5-A4EA-55DC-841B-745E391E2C90"><cmd/>+ −
<info>Use the created DOM tree. </info>+ −
<info>For example, refer to the <xref href="GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita">Searching+ −
a DOM Tree using XPath</xref> to search for specific elements or attributes+ −
in the DOM tree. </info>+ −
</step>+ −
<step id="GUID-9935393A-1359-5708-A9F3-B779F2E2B418"><cmd/>+ −
<info>Free your resources as necessary. </info>+ −
<substeps id="GUID-CB3D86A2-561D-5281-9DA4-AA8C70A0F498">+ −
<substep id="GUID-6D1DC97D-5068-5FCD-AD69-510778348899"><cmd>Close the parser+ −
and the engine by calling their <codeph>Close()</codeph> functions. </cmd>+ −
<stepxmp><codeblock id="GUID-53680EE0-8291-5C9A-9A7A-04437B1A0836" xml:space="preserve">+ −
parser.Close();+ −
impl.Close();+ −
</codeblock> </stepxmp>+ −
</substep>+ −
<substep id="GUID-1C28D8BE-D03B-5D9B-BCC7-355FB2A6A93C"><cmd/>+ −
<info>Close the XML library by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>XmlPopAndClose()</apiname></xref> method.+ −
This method also removes the serialisation resources from the clean-up stack. </info>+ −
</substep>+ −
<substep id="GUID-BCD8662A-7C1E-5239-87C9-E3917D79C326"><cmd/>+ −
<info>Perform any other clean-up operations. </info>+ −
</substep>+ −
</substeps>+ −
</step>+ −
</steps>+ −
</taskbody><related-links>+ −
<link href="GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita"><linktext>Searching+ −
a DOM Tree using XPath</linktext></link>+ −
<link href="GUID-E20C2C98-A294-551B-99CF-BE1DAA6F597E.dita"><linktext>Serialising+ −
XML DOM</linktext></link>+ −
</related-links></task>+ −