Method XmlNode():addElement() Foundation

Creates an element node and adds it as a child node.

Syntax
:addElement( <cName> [,<cContent>] [,<aAttributes>] ) --> oXmlNode
Parameters
<cName>
A character string with the node name to be used for the node.
<cContent>
A character string with the content value. This parameter is optional. If nothing is specified in the <cContent> parameter, the new node has no content defined.
<aAttributes>
An array that specifies the attributes to be defined for the node. The attributes may be specified either using a sub-array with attribute data, or via a DataObject that has the required information assigned to its member variables. This parameter is optional. If nothing is specified in the <aAttributes> parameter, the new node has no attributes defined.
In case arrays are to be used to define the attributes, a sub-array of the following format must be added for each attribute to the array in <aAttributes>:
{<cName>,<cValue>[,<cNamespace>]}
<cName> is the name of the attribute, and <cValue> specifies the attribute's value. If the attribute belongs to a certain namespace, the namespace name must be specified in the optional third array element.
As an alternative to using sub-arrays, the attributes of the new element node may also be specified using a DataObject. In this case, a DataObject with the following member variables must be assigned for each attribute to the array in <aAttributes>.
Members of the DataObjects in <aAttributes>
Name Data Type Description
name C Name of the attribute
value C Attribute value
namespace C Namespace the attribute belongs to
Return

:addElement() returns the object executing the method.

Description

The method :addElement() creates an element node using the specified node name, attributes and content, and associates it with the node object executing :addElement(). In order to create an element node which is not associated with any other node, the method :createElement() must be used.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.