Function EN Version 10.01

@XMLGetAttributes

XML

Syntax

@XMLGetAttributes(XMLN;AttributeNames);
@XMLGetAttributes(XMLN;AttributeNames;AttributeValues);
@XMLGetAttributes(XMLN;AttributeNames;AttributeValues;AttributeNamespaces);
@XMLGetAttributes(XMLN;AttributeNames;AttributeValues;AttributeNamespaces;AttributePrefixes);

Description

This @Function retrieves the attributes of an XML node.
The attribute names are returned as a text list. Optionally, the corresponding attribute values, namespace URIs, and namespace prefixes can also be returned in additional text lists.
All returned text values are converted to the desired character set according to the output flags set for the XML handle.

VSPECHXMLNODE XMLN:
Handle of the XML node whose attributes are to be retrieved.
XMLN must contain a valid VSPECHXMLNODE (XMLN) handle that references an XML node.

TEXTLIST AttributeNames:
Variable in which the names of all attributes of the XML node are returned as a text list.

TEXTLIST AttributeValues (Optional):
Variable in which the attribute values are returned as a text list.
The order corresponds to the AttributeNames text list, so each name and value can be matched by their respective list index.

TEXTLIST AttributeNamespaces (Optional)
Variable in which the namespace URIs of the attributes are returned as a text list.
If an attribute has no namespace, the corresponding list element contains an empty text value.

TEXTLIST AttributePrefixes (Optional)
Variable in which the namespace prefixes of the attributes are returned as a text list.
If an attribute has no namespace prefix, the corresponding list element contains an empty text value.

Return Value:
On successful execution, the @Function returns TRUE.
The retrieved information is returned through the supplied text list parameters. All specified lists contain their entries in the same order.
If the XML node handle is invalid, an error occurs during character set conversion, or an error occurs while creating a text list, the @Function returns @ERROR.

Example: @XMLGetAttributes(XMLN;AttributeNames);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer id=\"4711\" name=\"Example GmbH\" />";
hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
@XMLGetAttributes(hXMLRoot;AttributeNames);
@XMLRelease(hXMLD);

The example retrieves the names of all attributes of the root element. AttributeNames then contains the values "id" and "name".

Example: @XMLGetAttributes(XMLN;AttributeNames;AttributeValues;AttributeNamespaces;AttributePrefixes);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer xmlns:c=\"https://example.com/customer\" " +
"id=\"4711\" c:type=\"business\" />";
hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
@XMLGetAttributes(
hXMLRoot;
AttributeNames;
AttributeValues;
AttributeNamespaces;
AttributePrefixes
);

@XMLRelease(hXMLD);

The example retrieves the names, values, namespace URIs, and namespace prefixes of all attributes of the root element.
The individual text lists are positionally aligned, so the entries at the same list index belong together.

Note : This text was machine-translated and may contain inaccuracies.