@XMLGetChildByName
Syntax
@XMLGetChildByName(XMLN;Name);
@XMLGetChildByName(XMLN;Name;Namespace);
Description
This @Function retrieves the first direct child XML element with a specified name.
Optionally, a namespace can also be specified. In this case, both the element name and the namespace URI must match.
The search parameters are converted to UTF-8 according to the character set flags set for the XML handle.
The flags inherited from the supplied XML node handle are also applied to the returned XML node handle.
VSPECHXMLNODE XMLN:
Handle of the XML node whose direct child elements are to be searched.
XMLN must contain a valid VSPECHXMLNODE (XMLN) handle that references an XML node.
TEXT Name:
Name of the XML element to search for.
Only direct child XML elements are searched. Other node types, such as text or comment nodes, are ignored.
TEXT Namespace (Optional)
Namespace URI of the XML element to search for.
If no namespace is specified, the search is performed using the element name only.
If an empty text value ("") is specified as the namespace, the function explicitly searches for an element without a namespace.
Return Value:
If a matching element is found, the @Function returns a VSPECHXMLNODE (XMLN) handle referencing the first matching child element.
If no matching element is found or the supplied XML node handle is invalid, the @Function returns @ERROR.
Example: @XMLGetChildByName(XMLN;Name);
XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer>" +
" <name>Example GmbH</name>" +
" <city>Berlin</city>" +
"</customer>";
hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
hXMLName := @XMLGetChildByName(hXMLRoot;"name");
@XMLRelease(hXMLD);
The example retrieves the first direct child element with the name "name".
Example: @XMLGetChildByName(XMLN;Name;Namespace);
XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customer xmlns:c=\"https://example.com/customer\">" +
" <c:name>Example GmbH</c:name>" +
"</customer>";
hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
hXMLName := @XMLGetChildByName(hXMLRoot;"name";"https://example.com/customer");
@XMLRelease(hXMLD);
The example retrieves the first direct child element with the name "name" and the namespace URI "https://example.com/customer".
Note : This text was machine-translated and may contain inaccuracies.
