Parsing
XML DOM
This topic explains how to build a DOM tree by parsing an XML file.
Before you start, you must:
-
Call the
XmlEnginePushL()
method to
put parser resources on the clean-up stack.
XmlEnginePushL();
-
Initialise your
instance of the
RXmlEngDOMImplementation
class
by calling its
OpenL()
method.
RXMlEngDOMImplementation impl;
impl.OpenL();
The
RXMlEngDOMImplementation
instance is the DOM Engine.
-
Initialise the DOM parser by calling the
RXmlEngDOMParser::Open()
method
on its instance.
RXmlEngDOMParser parser;
parser.Open( impl );
You can also have several parsers registered on a DOM Engine instance.
-
Parse the specified XML file by calling the
RXmlEngDOMParser::ParseFileL()
method.
RXmlDocument myDoc = parser.ParseFileL( "tutorial.xml" );
The
myDoc
object is a DOM tree containing the data
from the XML file.
-
Use the created DOM tree.
For example, refer to the
Searching
a DOM Tree using XPath
to search for specific elements or attributes
in the DOM tree.
-
Free your resources as necessary.
-
Close the parser
and the engine by calling their
Close()
functions.
parser.Close();
impl.Close();
-
Close the XML library by calling the
XmlPopAndClose()
method.
This method also removes the serialisation resources from the clean-up stack.
-
Perform any other clean-up operations.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.