This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
DOM SET XML ELEMENT VALUE
|
DOM SET XML ELEMENT VALUE ( elementRef {; xPath}; elementValue {; *} ) | ||||||||
Parameter | Type | Description | ||||||
elementRef | String |
![]() |
XML element reference | |||||
xPath | Text |
![]() |
XPath path of the XML element | |||||
elementValue | String, Variable |
![]() |
New value of element | |||||
* | Operator |
![]() |
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 see the Support of XPath notation (DOM) section). The following path expressions are supported:
Expression | Action |
/ | Designates the root node (absolute path) |
para[1] | Designates the first para child of the context node |
para[last()] | Designates the last para child of the context node |
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.
Compatibility Note: Starting with v18 R3, the XPath implementation in 4D is more compliant. For compatibility reasons, the previous non-standard implementation is maintained by default in converted databases. If you want to benefit from the extended features in your converted databases, you need to select the Use standard XPath compatibility option of the Compatibility page.
In elementValue, pass a string or a variable (or a field) containing the new value of the specified element:
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).
Product: 4D
Theme: XML DOM
Number:
868
Modified: 4D 2004.4
Modified: 4D v11 SQL
4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)