XML_GET_FIRST_CHILD

Use the XML_GET_FIRST_CHILD script function to identify the first sub-element of an element in an XML document.

Tip: XML_GET_FIRST_CHILD identifies the element that is positioned one level to the right in the structure. Use XML_GET_NEXTSIBLING to identify the subsequent element on the same level. For more information, see XML_GET_NEXTSIBLING.

Syntax

XML_GET_FIRST_CHILD (Reference)

Script Function and Parameters

  • XML_GET_FIRST_CHILD
    Identifies the first sub-element of an element

  • Reference
    Reference to the element whose sub-element should 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 correct first sub-element. These handles are used by specific script elements for positioning themselves within the XML document, and editing it. The very first handle is the one, which XML_OPEN returns. 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 first sub-element or " " if there is no sub-element.

Example

The following example retrieves the name of the first sub-element of the 'Content' element. If there is one, it prints its name to the activation report. If not, it reports that there is no such sub-element.

Screenshot showing the Structured Documentation page called "Details" of a Calendar object called "ON_CALL_SERVICES"

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

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

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

:
XML_CLOSE

The example includes a first sub-element called 'Description' which is printed in the activation report:

Screenshort of the activation report that shows "Description" and the first child of the Structured Documentation page of the ON_CALL_SERVICES Calendar object.

See also: