@XMLAddChild
Syntax
@XMLAddChild(XMLN;Name);
@XMLAddChild(XMLN;Name;Content);
@XMLAddChild(XMLN;Name;Content;Namespace);
Description
This @Function creates a new direct child XML element below an existing XML node.
Optionally, content can be assigned to the new element directly. In addition, a namespace URI can be specified. In this case, the namespace must already be defined in the XML document.
The element name, optional content, and optional namespace URI are converted to UTF-8 according to the character set flags set for the XML handle.
The flags inherited from the parent node are also applied to the returned XML node handle.
VSPECHXMLNODE XMLN:
Handle of the parent node below which the new XML element is to be created.
XMLN must contain a valid VSPECHXMLNODE (XMLN) handle that references an XML node.
TEXT Name:
Name of the XML element to be created.
The name must not be empty and must be a valid XML NCName.
TEXT/VSPECBINBUFFER Content (Optional):
Content of the newly created XML element.
The content can be supplied as TEXT or VSPECBINBUFFER.
The maximum content size is 100 MB.
If no content is specified or the content is empty, an empty XML element is created.
TEXT Namespace (Optional):
Namespace URI to be assigned to the new XML element.
The specified namespace URI must already be defined in the XML document and must be accessible from the parent node.
If an empty text value ("") is specified as the namespace, the function explicitly creates an element without a namespace.
If a default namespace is active on the parent node, it is explicitly reset for the new element in this case.
Return Value:
On successful execution, the @Function returns a VSPECHXMLNODE (XMLN) handle referencing the newly created child element.
If the parent handle is invalid, the element name is empty or invalid, the specified namespace is not defined,
the content exceeds the maximum permitted size, or another error occurs while creating the element, the @Function returns @ERROR.
Example: @XMLAddChild(XMLN;Name);
Flags := 7;
hXMLD := @XMLCreate(Flags);
hXMLRoot := @XMLCreateRoot(hXMLD;"customer");
hXMLName := @XMLAddChild(hXMLRoot;"name");
@XMLRelease(hXMLD);
The example creates an empty "<name>" element below the root element.
Example: @XMLAddChild(XMLN;Name;Content);
Flags := 7;
hXMLD := @XMLCreate(Flags);
hXMLRoot := @XMLCreateRoot(hXMLD;"customer");
hXMLName := @XMLAddChild(hXMLRoot;"name";"Example GmbH");
@XMLRelease(hXMLD);
The example creates the "<name>" element with the content "Example GmbH".
Example: @XMLAddChild(XMLN;Name;Content;Namespace);
Flags := 7;
hXMLD := @XMLCreate(Flags);
hXMLRoot := @XMLCreateRoot(
hXMLD;
"customers";
"c";
"https://example.com/customer"
);
hXMLCustomer := @XMLAddChild(
hXMLRoot;
"customer";
"";
"https://example.com/customer"
);
@XMLRelease(hXMLD);
The example creates a new "<c:customer>" element in the already defined namespace "https://example.com/customer".
Note : This text was machine-translated and may contain inaccuracies.
