RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TXMLDocument.CreateNode Method

Creates a new node that is associated with this document.

Pascal
function CreateNode(const NameOrData: DOMString; NodeType: TNodeType = ntElement; const AddlData: DOMString = ''): IXMLNode;
C++
__fastcall IXMLNode CreateNode(const DOMString NameOrData, TNodeType NodeType = ntElement, const DOMString AddlData = '');

Call CreateNode to create a new generic XML node. The resulting node does not have a parent, but can be added to the ChildNodes or AttributeNodes list of any node in the document (including this document's ChildNodes property). It can also be assigned to the DocumentElement property to replace the entire data hierarchy of this document. 

NameOrData provides the tag name or value of the newly created node. Its interpretation depends on the type of node created, as indicated in the following table:

NodeType 
NameOrData 
ntElement  
The tag name.  
ntAttribute  
The attribute name.  
ntText  
The value of the node.  
ntCData  
The value of the CDATA section.  
ntEntityRef  
The name of the referenced entity.  
ntProcessingInstr  
The target of the processing instruction.  
ntComment  
The value (text) of the comment.  
ntDocFragment  
Not used.  
ntElement  
The namespace URI that qualifies the tag name.  
ntAttribute  
The namespace URI that qualifies the attribute name.  
ntProcessingInstr  
The content of the processing instruction, except for the target.  

NodeType indicates the type of node to create. It can only be one of the types listed in the previous table. 

The meaning of AddlData depends on the node type, as indicated in the following table:

NodeType 
AddlData 
ntElement  
The namespace URI that qualifies the tag name.  
ntAttribute  
The namespace URI that qualifies the attribute name.  
ntProcessingInstr  
The content of the processing instruction, except for the target.  

CreateNode returns the interface for the new node.

Note: To add a node as the child of another node in this document, it is simpler to call that node's AddChild method.
 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!