Adds a new XML element as a sub-element of this element. The new element is placed at the position specified through the document's DTD.

AddChild(XmlElement)

public bool AddChild(XmlElement element);
Public Function AddChild(ByVal element As XmlElement) As Boolean

AddChild(XmlElement, Int, Int)

public bool AddChild(XmlElement element, int before, int after);
Public Function AddChild(ByVal element As XmlElement, ByVal before As Integer, ByVal after As Integer) As Boolean

Parameters

Parameter Description
element Specifies the XML element to add.
before Specifies a relative position in the list of child elements of the specified type beginning with 1. The XML element to be added is placed before the child identified by the before parameter. You can specify before or after positions but not both. If this parameter is -1, it is ignored.
after Specifies a relative position in the list of child elements of the specified type beginning with 1. The XML element to be added is placed after the child identified by the after parameter. You can specify before or after positions but not both. If this parameter is -1, it is ignored.

Return Value

The return is false, if the new element could not be added because the document becomes invalid according to the document's DTD. In this case an XmlInvalid event occurs. The return value is true, if the new element could successfully been added.

Examples

The following examples creates a new Telephone element and adds it to the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone.

TXTextControl.XmlElement newElement = new TXTextControl.XmlElement("Telephone", "046798 / 3459786"); 

textControl1.GetXmlElements("Address").GetItem(2).AddChild(newElement);
Dim NewElement As New TXTextControl.XmlElement("Telephone", "046798 / 3459786") 
TextControl1.GetXmlElements("Address").GetItem(2).AddChild(NewElement