XML_GET_LAST_CHILD 

Use the XML_GET_LAST_CHILD script function to identify the last sub-element of an element in an XML document.

Tip: XML_GET_LAST_CHILD switches one level deeper into the structure, starting at the specified element. Use XML_GET_NEXTSIBLING to identify the next element on the same level. For more information, see XML_GET_NEXTSIBLING.

Syntax

XML_GET_LAST_CHILD (Reference)

Script Function and Parameters

  • XML_GET_LAST_CHILD
    Identifies the last sub-element of an element

  • Reference
    Reference to the element whose sub-element is to be identified
    Format: script literal or script variable
    Note: A reference or handle must be given to the script function so that it can access the appropriate last sub-element. This reference defines the position in the XML document. The very first handle is the one, which is returned by XML_OPEN. It refers to the Content root element of the structured documentation. For more information, see XML_OPEN.

Return Code

This script function returns the reference to the last sub-element or " " if there is no sub-element.

Example

The following example retrieves the name of the last sub-element in the content structure of the ON_CALL_SERVICES Calendar object. If there is one, its name is shown in the activation report. If not, the report indicates that there is no such sub-element.

Screenshot showing the Content structure of the @Details Structured Documentation page of the ON_CALL_SERVICES Calendar object. The structure includes the Description element, the Contacts element, and the Info element as its last sub-element of the Content structure

:SET &XMLDOCU# = XML_OPEN (DOCU,"ON_CALL_SERVICES","@Details")

:
SET &HND# = XML_GET_LAST_CHILD (&XMLDOCU#)

:   
IF &HND# <> ""
:      
SET &NAME# = XML_GET_NODE_NAME (&HND#)
:      
PRINT "Last sub-element: &NAME#"
:   
ELSE
:     
 PRINT "No sub-element"
:  
 ENDIF

:
XML_CLOSE

The activation report shows the name of the last sub-element 'Info':

Screenshot of the activation report of XML_GET_LAST_CHILD showing the last sub-element 'Info' of the ON_CALL_SERVICES Calendar object's @Details Structured Documentation page.

See also: