XML_REMOVE_CHILDREN
Use the XML_REMOVE_CHILDREN script function to delete all subordinate elements of a specific open element within the XML document. XML_REMOVE_CHILDREN returns code 0 once the sub-elements are successfully deleted.
Important Considerations
Keep the following rules and tips in mind when using this script function:
- Important! The XML structure is modified in the memory only. You do not see the changes of XML_REMOVE_CHILDREN on the structured documentation page.
- Tip: Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.
Syntax
XML_REMOVE_CHILDREN (Element)
Parameters
| Parameter | Description | Format | Allowed Values |
|---|---|---|---|
| Element | Reference to the element whose sub-element will be deleted. | Script literal or script variable | n.a. |
Return Codes
0: All sub-elements of the specified element were successfully deleted.
Examples
The following example opens a structured documentation page as an XML document. The first element is specified and all of its sub-elements are deleted. If the deletion is successful, a corresponding message is written to the activation log:
:SET &XMLDOCU#=XML_OPEN(DOCU,,"@Details")
: IF &XMLDOCU# <> ""
:SET &FIRST# = XML_GET_FIRST_CHILD(&XMLDOCU#)
:SET &RET# = XML_REMOVE_CHILDREN(&FIRST#)
:IF &RET# = 0
:P 'Sub-element successfully deleted.'
: ENDIF
:ENDIF
:XML_CLOSE &XMLDOCU#
See also: