Xml.XMLDoc.TXMLNode.AddChild

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function AddChild(const TagName: DOMString; Index: Integer = -1): IXMLNode; overload;
function AddChild(const TagName, NamespaceURI: DOMString;
GenPrefix: Boolean = False; Index: Integer = -1): IXMLNode; overload;
function AddChild(const TagName, NamespaceURI: DOMString;
NodeClass: TXMLNodeClass; Index: Integer = -1): IXMLNode; overload;

C++

Xml::Xmlintf::_di_IXMLNode __fastcall AddChild(const System::UnicodeString TagName, int Index = 0xffffffff)/* overload */;
Xml::Xmlintf::_di_IXMLNode __fastcall AddChild(const System::UnicodeString TagName, const System::UnicodeString NamespaceURI, bool GenPrefix = false, int Index = 0xffffffff)/* overload */;
Xml::Xmlintf::_di_IXMLNode __fastcall AddChild(const System::UnicodeString TagName, const System::UnicodeString NamespaceURI, TXMLNodeClass NodeClass, int Index = 0xffffffff)/* overload */;

Properties

Type Visibility Source Unit Parent
function protected
Xml.XMLDoc.pas
Xml.XMLDoc.hpp
Xml.XMLDoc TXMLNode

Description

Adds a new child node to this node.

Use the TXMLNode object's IXMLNode interface to call the protected AddChild method. Only the first two versions of AddChild are available on the IXMLNode interface. The third syntax is used by TXMLNode descendants that the XML data binding wizard creates.

AddChild creates a new element node as the child of this node.

TagName provides the tag name of the newly created node.

Index indicates the position of the child node in this node's list of children, where 0 is the first position, 1 is the second position, and so on. If Index is –1, the new node is added to the end.

NamespaceURI identifies the namespace that includes the new node's definition. If NamespaceURI is omitted (the first syntax), the namespace of the new node is deduced from the namespace prefix of TagName. If TagName has no namespace prefix and there is no NamespaceURI parameter, the namespace is the same as this node's NamespaceURI property.

GenPrefix controls whether AddChild generates a namespace prefix for the namespace URI when the NamespaceURI parameter identifies a URI that is not already declared in the document. Note that setting GenPrefix to true does not cause AddChild to add a declaration of the new namespace prefix unless the document's Options property includes doNamespaceDecl.

NodeClass identifies the implementation class to use for the new child node. It must be TXMLNode or one of its descendants.

AddChild returns the interface for the newly created child node.

Tip: AddChild only adds element nodes. To add other types of child nodes, use the XML document's CreateNode method instead, and then add the resulting node to the ChildNodes property array.

See Also