4D v16.3

DOM SET XML ELEMENT VALUE

Home

 
4D v16.3
DOM SET XML ELEMENT VALUE

DOM SET XML ELEMENT VALUE 


 

DOM SET XML ELEMENT VALUE ( elementRef {; xPath}; elementValue {; *} ) 
Parameter Type   Description
elementRef  String in XML element reference
xPath  Text in XPath path of the XML element
elementValue  String, Variable in New value of element
Operator in If passed: set the value in CDATA

The DOM SET XML ELEMENT VALUE command modifies the value of the element set by elementRef.

If you pass the optional xPath parameter, you choose to use XPath notation to indicate the element to be modified (for more information about this notation, refer to the section Use of XPath notation (DOM)). In this case, you must pass the reference of a root XML element in elementRef and the XPath path of the element to be modified in xPath .

In elementValue, pass a string or a variable (or a field) containing the new value of the specified element:

  • If you pass a string, the value is used “as is” in the XML structure.
  • If you pass a variable or a field, 4D processes the value, depending on the type of elementValue. All data types can be used, except arrays, pictures and pointers.

When the optional asterisk (*) parameter is passed, this indicates that the value of the element must be set in the form of CDATA. The special CDATA form can be used to write raw text as is (see example 2).

Note: If the element designated by elementRef is a BLOB processed by this command, it is automatically encoded in base64. In this case, the DOM GET XML ELEMENT VALUE command does automatically the reverse operation.

To comply with XML processing rules, all CR and CRLF end-of-line characters are replaced by LF characters.

In the following XML source:

<Book>
   <Title>The Best Seller</Title>
</Book>

If the following code is executed, with vElemRef containing the reference to the “Title” element:

 DOM SET XML ELEMENT VALUE(vElemRef;"The Loser")

We get:

<Book>
   <Title>The Loser</Title>
</Book>

In the following XML source:

<Maths>
   <Postulate>1+2=3</Postulate>
</Maths>

We want to write the text “12<18” in the <Postulate> element. This string cannot be written as is in XML because the “<” character is not accepted. This character must therefore be changed into “<” or the CDATA form must be used. If vElemRef indicates the XML <Postulate> node:

  ` Normal form
 DOM SET XML ELEMENT VALUE(vElemRef;"12<18")

We get:

<Maths>
   <Postulate>12 < 18</Postulate>
</Maths>


  ` CDATA form
 DOM SET XML ELEMENT VALUE(vElemRef;"12<18";*)

We get:

<Maths>
   <Postulate><![CDATA[12 < 18]]></Postulate>
</Maths>

If the command has been executed correctly, the system variable OK is set to 1. Otherwise, it is set to 0 and an error is generated (for example, if the element reference is invalid).



See also 

DOM GET XML ELEMENT VALUE
XML SET OPTIONS

 
PROPERTIES 

Product: 4D
Theme: XML DOM
Number: 868

The OK variable is changed by the commandThis command modifies the Error system variableThis command can be run in preemptive processes

 
HISTORY 

Modified: 4D 2004.4
Modified: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)