Share via


IXMLNodeFactory::CreateNode

4/8/2010

This method is the main method that is called during parsing for every element.

Syntax

HRESULT CreateNode( 
  IXMLNodeSource * pSource,
  PVOID pNodeParent,
  USHORT cNumRecs,
  XML_NODE_INFO * apNodeInfo
);

Parameters

  • pSource
    [in] The node source is passed into each node factory call so that the node factory can call back and obtain important information, such as the current line number, or stop the parser
  • pNodeParent
    [in] This is the parent object of the node being created. This parent pointer was returned from a prior IXMLNodeFactory::CreateNode call or is the root object provided by using the parser IXMLParser::SetRoot method.
  • cNumRecs
    [in] Number of XML_NODE_INFO structures
  • apNodeInfo
    [in] Pointer to an array of pointers to XML_NODE_INFO structures. The first member is the node information for the elements. The second through last members of the array contain attribute name nodes, followed by attribute value nodes. For example, for <a y="2" x="sample&tag;blech">, the array resembles the following.

    Element "a"
    Attribute "y"
    #PCDATA "2"
    Attribute "x"
    #PCDATA "sample"
    EntityRef "tag"
    #PCDATA "more...."
    

Return Value

  • HRESULT
    -

Remarks

  • When fTerminal is TRUE, there are no BeginChildren or EndChildren. This happens when the node type implies that there can never be any child nodes according to the XML language specification.
  • Empty tags (such as the dsig tag) do not have a BeginChildren. However, they do have an EndChildren that specifies the fEmpty argument as TRUE.
  • XML_ATTRIBUTE nodes can have multiple child nodes as shown in the case in which the title attribute contains both XML_PCDATA and an XML_ENTITYREF node.
  • XML_WHITESPACE nodes can usually be completely ignored by the node factory (which is why they differ from XML_PCDATA) unless the node factory cares about preserving the original document format.

Code Example

The following code example shows how to use CreateNode.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it was modified to include them.

Consider the following XML fragment.

<item id="SAMPLE" ms:price="20" title="TAG &sample;" xmlns:price="URIXX" >
    <value>The quick brown fox</value>
    <dsig id="1412231"/>
</item>

The following sequence of calls will be made on the node factory. This example is indented for readability only. It is not meant to imply recursion.

CreateNode XML_ELEMENT: [item]
      XML_ATTRIBUTE: [id]
      XML_PCDATA: [SAMPLE]
      XML_ATTRIBUTE: [ms][price]
      XML_PCDATA: [20]
      XML_ATTRIBUTE: [title]
      XML_PCDATA: [TAG ]
      XML_ENTITYREF: [sample]
      XML_ATTRIBUTE: [xmlns][price]
      XML_PCDATA: [URIXX]
BeginChildren
 CreateNode XML_WHITESPACE: 0D0A09 (fTerminal=TRUE)
 CreateNode XML_ELEMENT: [value]
 BeginChildren
  CreateNode XML_PCDATA: [The quick brown fox](fTerminal=TRUE)
 EndChildren
 CreateNode XML_WHITESPACE: 0D0A09 (fTerminal=TRUE)
 CreateNode XML_ELEMENT: [dsig]
       XML_ATTRIBUTE: [id]
       XML_PCDATA: [1412231]
 EndChildren (fEmpty=TRUE)
 CreateNode XML_WHITESPACE: 0D0A (fTerminal=TRUE)
EndChildren

Requirements

Header xmlparser.h
Library xmlparser.lib
Windows Mobile Pocket PC 2000 and later, Smartphone 2002 and later

See Also

Reference

IXMLNodeFactory
IXMLParser::SetRoot
XML_NODE_INFO