XML_DELETE_NODE

Use the XML_DELETE_NODE script function to delete a specific element from an open XML document. You can define the reference to the element you want to delete. Sub-elements of the specified element, if existing, are also deleted.

Important! The XML structure is modified in the memory only. You do not see the changes of XML_DELETE_NOTE 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_DELETE_NODE (Element)

Script Function and Parameters

  • XML_DELETE_NODE
    Removes a specific XML element

  • Element
    Reference to the element to be deleted.
    Format: script literal or script variable

Return Code

  • 0
    The element has been successfully deleted

Example

The following example opens the @Details structured documentation page of the own object as an XML document, captures the first element, and deletes it:

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

:IF &XMLDOCU# <>
""
:SET &FIRST# = XML_GET_FIRST_CHILD(&XMLDOCU#)
:SET &DELETE# = XML_DELETE_NODE(&FIRST#)

:IF &DELETE# = 0
:P 'First XML element successfully deleted'
:ELSE 

: P 'An error occurred while deleting the XML element'

:ENDIF

:ENDIF
:P &XMLDOCU#

:XML_CLOSE

The activation report indicates whether the deletion process was successful:

Screenshot of the XML_DELETE_NODE Script object showing the  successful deletion of the first XML element.

See also: