Symbian3/SDK/Source/GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-92C2317A-57B8-558E-984B-B10FD0404981.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,59 @@
+<?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-92C2317A-57B8-558E-984B-B10FD0404981" xml:lang="en"><title>Searching
+a DOM Tree using XPath</title><shortdesc>This topic explains how to search in a DOM tree using an XPath
+expression. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
+<prereq><p>Before you start, you must: </p> <ul>
+<li id="GUID-3B777E07-07AE-5EF0-8CB1-F07217AFB2C2"><p>understand <xref href="http://www.w3schools.com/XPath/xpath_syntax.asp" scope="external">XPath syntax</xref> and the concept of <xref href="http://www.w3.org/DOM/" scope="external">Document Object Model (DOM)</xref>. </p> </li>
+<li id="GUID-ADB75A14-811C-53F9-90C3-B068D1506EE1"><p>understand the architecture
+and classes of the <xref href="GUID-5ACFA8E4-3C4B-5851-A43E-9FA72D0B8403.dita">XML
+Engine</xref> component. </p> </li>
+<li id="GUID-1AF969E2-E11F-538B-A33C-762B1F0E5EA6"><p>have created an <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngDocument</apiname></xref> (called <codeph>myDoc</codeph> in this
+example), either by parsing an XML file (as indicated in the <xref href="GUID-C5C30218-311C-58D9-A990-3F95642F7517.dita">XML
+DOM Parsing Tutorial</xref>) or by adding nodes to a new DOM tree. </p> </li>
+</ul> </prereq>
+<context><p>XPath is a simple query language for XML. An XPath expression
+describes a subset of an XML tree, such as all the elements with a specified
+name, or all the children of a specific node. Evaluating an XPath expression
+means searching in the XML tree for matching nodes or content: clients of
+the XML Engine use it to explore XML data. </p> <p>The following steps show
+how to make an XPath query with the XML Engine. </p> </context>
+<steps id="GUID-AE83D04E-2094-5F9C-AD56-D9803C96FB2C">
+<step id="GUID-3E1709B9-A282-533F-B893-3E4962B29AA4"><cmd>Create an instance
+of <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>RXmlEngXPathExpression</apiname></xref> by calling the <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>TXmlEngXpathEvaluator::CreateExpressionL()</apiname></xref> method. </cmd>
+<stepxmp><codeblock id="GUID-95ED0151-D8E7-5CB2-9F3A-90C691B253B1" xml:space="preserve">RXmlEngXPathExpression expr = TXmlEngXpathEvaluator::CreateExpressionL( "@*" );</codeblock> </stepxmp>
+<info>This XPath expression is only useful to illustrate this tutorial: it
+returns all the attributes in an XML tree. </info>
+</step>
+<step id="GUID-77F768C2-E2F8-55AF-AAC3-DF95347AFBD2"><cmd/>
+<info>Evaluate the XPath expression by applying it to your XML document. </info>
+<stepxmp><codeblock id="GUID-65F9578E-CF76-5CCA-A8F5-D73E32C7D9D8" xml:space="preserve">RXmlEngXPathResult searchResult = expr.EvaluateL( myDoc );</codeblock> </stepxmp>
+<stepresult>The <codeph>searchResult</codeph> variable contains a tree of <xref href="GUID-5748D958-9480-3358-A399-6B92293B86D9.dita"><apiname>TXmlEngAttr</apiname></xref> objects. This tree is a subset of the DOM
+tree. </stepresult>
+</step>
+<step id="GUID-C9981839-7BDB-5448-B161-A3524DD79AC9"><cmd/>
+<info>Use the result, for example by accessing it as a node set as follows: </info>
+<stepxmp><codeblock id="GUID-ABFD2D88-C8A0-58FE-9408-05B3F2714794" xml:space="preserve">RXMLEngNodeSet set = result.AsNodeSet();
+if( for TInt i = 0; i &lt; set.Length(); i++ )
+    {
+    TXmlEngNode resultNode = set[i];
+    /* [...] do something with the result */
+    }</codeblock> </stepxmp>
+</step>
+<step id="GUID-0D55DFAA-B583-5582-B197-8D07DEF37636"><cmd/>
+<info>Free your resources as necessary. </info>
+</step>
+</steps>
+</taskbody><related-links>
+<link href="GUID-E20C2C98-A294-551B-99CF-BE1DAA6F597E.dita"><linktext>Serialising
+XML DOM</linktext></link>
+</related-links></task>
\ No newline at end of file