XML_SET_NODE_TEXT

Script function: Changes or sets the value of an XML element.

Syntax

XML_SET_NODE_TEXT (Element, Value)

Syntax part

Description/format

Element

Reference to the element whose value is to be changed/ set.
Format: script literal or script variable

Value Value for the element.
Format: script literal or script variable


 

Return code

'0' – The value of the element was successfully set.

The script element sets the value of a specific element within the XML document that is open. Specify a reference to the element and the new value.

Notes:

  • If the element already has a value, the value will be changed.
  • The element will only be modified in the memory. The script element does not have an effect on the Documentation tab.
  • Use the XML_OPEN script function to open the XML document. For more information, see XML_OPEN.

Tip: Line breaks are allowed in the value of the element. Use the UC_CRLF script function to insert line breaks. For more information, see UC_CRLF.

Example

The following example opens the structured Documentation tab as an XML document, captures the first element and outputs its value in the activation log. The value of the element will then be changed. If this action is successful, the new value will be detected by means of a test and also 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 log:

2013-08-14 13:32:27 – U0020408 Old Value: Old Node Text
2013-08-14 13:32:27 – U0020408 New Value: New Node Text

See also: