Automation Engine Script Guide > Ordered by Function > Read or Modify Objects > XML_SET_NODE_TEXT

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.

Notes

The script element sets the value of a specific element within the XML document that is open. If the element already has a value, this will be changed. You need to specify a reference to the element and the new value.

The element is only stored in the memory using the script function. The Documentation tab is not affected by this.

Line breaks are allowed in the value of the element. Use the UC_CRLF script element to insert line breaks.

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:

Script element Description
XML_OPEN Opens an XML document for processing.
:XML_CLOSE Closes an XML document.