Share via


IXMLNodeFactory::CreateNode

Send Feedback

This method is the main method that gets 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 get 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 looks like the following.

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

Return Values

  • 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 (like 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 where the title attribute contains both XML_PCDATA and an XML_ENTITYREF node.
  • XML_WHITESPACE nodes can usually be entirely ignored by the node factory (which is why they are different from XML_PCDATA) unless the node factory cares about preserving the original document format.

Code Example

The following code example demonstrates 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 has been 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

Pocket PC: Pocket PC 2000 and later
Smartphone: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: xmlparser.h
Library: xmlparser.lib

See Also

IXMLNodeFactory | IXMLParser::SetRoot | XML_NODE_INFO

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.