XML_SET_NODE_TEXT

Use the XML_SET_NODE_TEXT script function to change or set the value of a specific element within the open XML document.

Tips:

  • The element is modified in the memory only. The script function does not affect the Documentation page.
  • Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.

Syntax

XML_SET_NODE_TEXT (Element, Value)

Script Function and Parameters

  • XML_SET_NODE_TEXT
    Sets the value of a specific element withing the open XML document

  • Value
    Value for the element
    Format: script literal or script variable
    Notes:

    • If the element already has a value, this value changes.
    • You can use line breaks in the value of the element. Use the UC_CRLF script function to insert line breaks. For more information, see UC_CRLF.

Return Code

  • 0
    The value of the element was successfully set

Example

The following example opens the @Details structured documentation page as an XML document, captures the first element, and outputs its value in the activation report. The value of the element changes, and if this action succeeds, the new value is detected through a test and written to the activation report.

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

:IF &XMLDOCU# <>
""

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

:SET &VALUE# = XML_GET_NODE_TEXT(&ELEMENT#)
:P "Old Value: &VALUE#"

:SET &RET# = XML_SET_NODE_TEXT(&ELEMENT#,"New Node Text")

:IF &RET# = 0

:SET &VALUE# = XML_GET_NODE_TEXT(&ELEMENT#)
:P "New Value: &VALUE#"

:ENDIF

:ENDIF

:XML_CLOSE &XMLDOCU#

Sample output in the activation report:

2023-05-14 13:32:27 – U0020408 Old Value: Old Node Text
2023-05-14 13:32:27 – U0020408 New Value: New Node Text

See also: