DOM Create XML Ref
DOM Create XML Ref ( root {; nameSpace} {; nameSpaceName ; nameSpaceValue} {; nameSpaceName2 ; nameSpaceValue2 ; ... ; nameSpaceNameN ; nameSpaceValueN} ) : Text
Parameter | Type | Description | |
---|---|---|---|
root | Text | → | Name of root element |
nameSpace | Text | → | Value of namespace |
nameSpaceName | Text | → | Namespace name |
nameSpaceValue | Text | → | Namespace value |
Function result | Text | ← | Root XML element reference |
Description
The DOM Create XML Ref command creates an empty XML tree in memory and returns its reference.
Pass the name of the XML tree root element in the root parameter.
Pass the declaration of the namespace value of the tree in the optional nameSpace parameter (for example, “http://www.4d.com”).
Note that you can prefix the root parameter with the namespace name followed by a colon : (for example “MyNameSpace:MyRoot”). In this case, the nameSpace parameter specifying the namespace value is mandatory.
Note: The namespace is a string that allows you to make sure the XML variable names are unique. In general, a URL like http://www.mysite.com/myurl is used. The URL does not necessarily have to be valid, but it does have to be unique.
You can declare one or more additional namespaces in the generated XML tree using nameSpaceName/nameSpaceValue pairs. You can pass as many namespace name/value pairs as you want.
Important: Remember to call the DOM CLOSE XML command in order to free up the memory when you have finished using the XML tree.
Example 1
Creating a single XML tree:
var vElemRef : Text
vElemRef:=DOM Create XML Ref("MyRoot")
This code produces the following result:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<MyRoot/>
Example 2
Creating an XML tree with a single namespace:
var vElemRef : Text
$Root:="MyNameSpace:MyRoot"
$Namespace:="http://www.4D.com/tech/namespace"
vElemRef:=DOM Create XML Ref($Root;$Namespace)
This code produces the following result:
<MyNameSpace:MyRoot xmlns:MyNameSpace="http://www.4D.com/tech/namespace"/>
Example 3
Creating an XML tree with several namespaces:
var vElemRef : Text
var $aNSName1;$aNSName2;$aNSValue1;$aNSValue2 : Text
$Root:="MyNameSpace:MyRoot"
$Namespace:="http://www.4D.com/tech/namespace"
$aNSName1:="NSName1"
$aNSName2:="NSName2"
$aNSValue1:="http://www.4D.com/Prod/namespace"
$aNSValue2:="http://www.4D.com/Mkt/namespace"
vElemRef:=DOM Create XML Ref($Root;$Namespace;$aNSName1;$aNSValue1;$aNSName2;$aNSValue2)
This code produces the following result:
<MyNameSpace:MyRoot xmlns:MyNameSpace="http://www.4D.com/tech/nameSpace"
NSName1="http://www.4D.com/Prod/namespace"
NSName2="http://www.4D.com/Mkt/namespace"/>
System variables and sets
If the command was executed correctly, the system variable OK is set to 1. Otherwise, it is set to 0 and an error is generated.