@XMLCreateRoot
Syntax
@XMLCreateRoot(XMLD;Root);
@XMLCreateRoot(XMLD;Root;Prefix;Namespace);
Description
This @Function creates the root element of an XML document previously created with @XMLCreate.
Optionally, one or more namespace prefixes and their corresponding namespace URIs can also be specified. The first specified namespace pair is assigned to the root element as its namespace.
Additional namespace pairs are declared on the root element.
Exactly two call variants are supported: either with two parameters or with four parameters. A variant with three parameters is not supported.
The root element name, prefixes, and namespace URIs are converted to UTF-8 according to the character set flags set for the XML document.
The flags inherited from the XML document are also applied to the returned XML node handle.
VSPECHXMLDOC XMLD:
Handle of the XML document in which the root element is to be created.
XMLD must contain a valid VSPECHXMLDOC (XMLD) handle.
The XML document must not already contain a root element.
TEXT Root:
Name of the root element to be created.
The name must not be empty and must be a valid XML NCName.
TEXT/TEXTLIST Prefix (Optional):
Namespace prefix or list of namespace prefixes.
An empty prefix is allowed and defines a default namespace.
Non-empty prefixes must be valid XML NCNames.
TEXT/TEXTLIST Namespace (Optional):
Namespace URI or list of namespace URIs corresponding to the specified prefixes.
Prefix and Namespace must contain the same number of elements.
At least one namespace must be specified. Namespace URIs must not be empty.
The first prefix/namespace pair is assigned to the root element as its namespace. Additional pairs are declared on the root element.
Return Value:
On successful execution, the @Function returns a VSPECHXMLNODE (XMLN) handle referencing the newly created root element.
If the XML document already contains a root element, the root name is invalid, the numbers of prefixes and namespaces do not match, a prefix or namespace is invalid,
or another error occurs while creating the element, the @Function returns @ERROR.
Example: @XMLCreateRoot(XMLD;Root);
Flags := 7;
hXMLD := @XMLCreate(Flags);
hXMLRoot := @XMLCreateRoot(hXMLD;"customer");
@XMLRelease(hXMLD);
The example creates the root element "<customer>" in a previously created XML document.
Example: @XMLCreateRoot(XMLD;Root;Prefix;Namespace);
Flags := 7;
hXMLD := @XMLCreate(Flags);
hXMLRoot := @XMLCreateRoot(
hXMLD;
"customer";
"c";
"https://example.com/customer"
);
@XMLRelease(hXMLD);
The example creates a root element with the namespace prefix "c" and the namespace URI "https://example.com/customer".
The resulting element is equivalent to:
<c:customer xmlns:c="https://example.com/customer"/>
Note : This text was machine-translated and may contain inaccuracies.
