diff -r ebc84c812384 -r 46218c8b8afa Symbian3/PDK/Source/GUID-2468D736-9F95-5412-B687-765D630651C7.dita --- a/Symbian3/PDK/Source/GUID-2468D736-9F95-5412-B687-765D630651C7.dita Thu Mar 11 15:24:26 2010 +0000 +++ b/Symbian3/PDK/Source/GUID-2468D736-9F95-5412-B687-765D630651C7.dita Thu Mar 11 18:02:22 2010 +0000 @@ -1,76 +1,76 @@ - - - - - -Parsing -the XML Data -

XML Parser is used to convert XML data to and from the DOM tree structure.The -end result of the XML parsing is a DOM tree structure. In the case of SMIL, -the player can use this DOM tree to render the slides.

-
Introduction

In order to parse XML data, an instance -of the parser must be created. Two types of constructors exist, one type takes -a MXMLDtd object, while the other does not. If a DTD object -is supplied, then the parser validates the XML according to that DTD. If no -DTD class is provided, then no validation takes place.

All of the -constructors take a MMDXMLParserObserver parameter. This -interface is usually implemented by the owning class which then passes itself -to the parser constructor. This interface exists so that the parser can notify -its owner when parsing is complete.

The way in which the DOM tree -is used varies depending on the type of XML and even between different clients -of the same type of XML. Different SMIL players may walk the DOM tree in slightly -different ways; however several functions are likely to be used by all XML -clients.

-
Procedure
    -
  1. Generate a DOM tree from XML data.

  2. -
  3. Extract the data from the DOM tree.

  4. -

Generate a DOM -tree from XML data

The following are the steps required to parse -XML data and get the DOM tree:

    -
  1. Call CMDXMLParser::ParseFile(), -passing in the filename of the XML document to be parsed.

    When the -parsing is complete, the parser calls the observer's ParseFileCompleteL() function. -This function must initiate the handling of the DOM tree that has been generated -by the parser.

  2. -
  3. Call CMDXMLParser::DetachXMLDoc() to -take ownership of the parsed DOM tree.

  4. -
  5. Call CMDXMLDocument::DocumentElement() to -get the root element of the DOM tree.

  6. -

Extract data from -the DOM tree

The DOM tree is made up of CMDXMLNode objects. -The document element that is returned by the final step of the previous section -is an example of a CMDXMLNode.

Use the following -functions to navigate the DOM tree:

    -
  • CMDXMLNode::HasChildNodes()

  • -
  • CMDXMLNode::FirstChild()

  • -
  • CMDXMLNode::LastChild()

  • -
  • CMDXMLNode::NextSibling()

  • -
  • CMDXMLNode::PreviousSibling()

  • -

Once a child or sibling node has been located, it is necessary to -cast it to the specific type. The type can be identified by calling CMDXMLNode::NodeType(). -The following types of node might exist in a parsed DOM tree. Once the type -has been identified, they must be cast to one of the following:

    -
  • CMDXMLComment: -Comment data.

  • -
  • CMDXMLProcessingInstruction: -Processing instruction data.

  • -
  • CMDXMLText: -Text data.

  • -
  • CMDXMLElement: -Element data including attribute name/value pairs.

  • -
  • CMDXMLDocumentElement: -Represents the root element in the DOM tree. This is the first node that is -accessible after parsing is complete.

  • -
-
-SMIL Parser -Overview -Composing -the XML Data + + + + + +Parsing +the XML Data +

XML Parser is used to convert XML data to and from the DOM tree structure.The +end result of the XML parsing is a DOM tree structure. In the case of SMIL, +the player can use this DOM tree to render the slides.

+
Introduction

In order to parse XML data, an instance +of the parser must be created. Two types of constructors exist, one type takes +a MXMLDtd object, while the other does not. If a DTD object +is supplied, then the parser validates the XML according to that DTD. If no +DTD class is provided, then no validation takes place.

All of the +constructors take a MMDXMLParserObserver parameter. This +interface is usually implemented by the owning class which then passes itself +to the parser constructor. This interface exists so that the parser can notify +its owner when parsing is complete.

The way in which the DOM tree +is used varies depending on the type of XML and even between different clients +of the same type of XML. Different SMIL players may walk the DOM tree in slightly +different ways; however several functions are likely to be used by all XML +clients.

+
Procedure
    +
  1. Generate a DOM tree from XML data.

  2. +
  3. Extract the data from the DOM tree.

  4. +

Generate a DOM +tree from XML data

The following are the steps required to parse +XML data and get the DOM tree:

    +
  1. Call CMDXMLParser::ParseFile(), +passing in the filename of the XML document to be parsed.

    When the +parsing is complete, the parser calls the observer's ParseFileCompleteL() function. +This function must initiate the handling of the DOM tree that has been generated +by the parser.

  2. +
  3. Call CMDXMLParser::DetachXMLDoc() to +take ownership of the parsed DOM tree.

  4. +
  5. Call CMDXMLDocument::DocumentElement() to +get the root element of the DOM tree.

  6. +

Extract data from +the DOM tree

The DOM tree is made up of CMDXMLNode objects. +The document element that is returned by the final step of the previous section +is an example of a CMDXMLNode.

Use the following +functions to navigate the DOM tree:

    +
  • CMDXMLNode::HasChildNodes()

  • +
  • CMDXMLNode::FirstChild()

  • +
  • CMDXMLNode::LastChild()

  • +
  • CMDXMLNode::NextSibling()

  • +
  • CMDXMLNode::PreviousSibling()

  • +

Once a child or sibling node has been located, it is necessary to +cast it to the specific type. The type can be identified by calling CMDXMLNode::NodeType(). +The following types of node might exist in a parsed DOM tree. Once the type +has been identified, they must be cast to one of the following:

    +
  • CMDXMLComment: +Comment data.

  • +
  • CMDXMLProcessingInstruction: +Processing instruction data.

  • +
  • CMDXMLText: +Text data.

  • +
  • CMDXMLElement: +Element data including attribute name/value pairs.

  • +
  • CMDXMLDocumentElement: +Represents the root element in the DOM tree. This is the first node that is +accessible after parsing is complete.

  • +
+
+SMIL Parser +Overview +Composing +the XML Data
\ No newline at end of file