Function EN Version 10.01

@XMLGetNextSiblingByName

XML

Syntax

@XMLGetNextSiblingByName(XMLN;Name);
@XMLGetNextSiblingByName(XMLN;Name;Namespace);

Description

This @Function retrieves the next XML sibling element with a specified name.
The search starts with the immediately following sibling element of the supplied XML node and continues until an element with a matching name is found.
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 from which the search for the next matching sibling element is to begin.
XMLN must contain a valid VSPECHXMLNODE (XMLN) handle that references an XML node.

TEXT Name:
Name of the XML element to search for.
Only following sibling 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 following matching sibling element.
If no matching element is found or the supplied XML node handle is invalid, the @Function returns @ERROR.

Example: @XMLGetNextSiblingByName(XMLN;Name);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customers>" +
" <customer>First</customer>" +
" <city>Berlin</city>" +
" <customer>Second</customer>" +
"</customers>";

hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
hCustomer1 := @XMLGetChildByName(hXMLRoot;"customer");
hCustomer2 := @XMLGetNextSiblingByName(hCustomer1;"customer");
@XMLRelease(hXMLD);

The example first retrieves the first "<customer>" element and then the next sibling element with the same name.

Example: @XMLGetNextSiblingByName(XMLN;Name;Namespace);

XML := "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<customers xmlns:c=\"https://example.com/customer\">" +
" <c:customer>First</c:customer>" +
" <customer>Other</customer>" +
" <c:customer>Second</c:customer>" +
"</customers>";

hXMLD := @XMLParse(XML);
hXMLRoot := @XMLGetRoot(hXMLD);
hCustomer1 := @XMLGetChildByName(hXMLRoot;"customer";"https://example.com/customer");
hCustomer2 := @XMLGetNextSiblingByName(hCustomer1;"customer";"https://example.com/customer");
@XMLRelease(hXMLD);

The example retrieves the next sibling element with the name "customer" and the namespace URI "https://example.com/customer".

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