4D v13.4

DOM Create XML Ref

Home

 
4D v13.4
DOM Create XML Ref

DOM Create XML Ref 


 

DOM Create XML Ref ( root {; nameSpace} {; nameSpaceName ; nameSpaceValue} {; nameSpaceName2 ; nameSpaceValue2 ; ... ; nameSpaceNameN ; nameSpaceValueN} ) -> Function result 
Parameter Type   Description
root  String in Name of root element
nameSpace  String in Value of namespace
nameSpaceName  String in Namespace name
nameSpaceValue  String in Namespace value
Function result  String in Root XML element reference

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.

Creating a single XML tree:

 C_TEXT(vElemRef)
 vElemRef:=DOM Create XML Ref("MyRoot")

This code produces the following result:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> 
<MyRoot/>

Creating an XML tree with a single namespace:

 C_TEXT(vElemRef)
 $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"/>


Creating an XML tree with several namespaces:

 C_TEXT(vElemRef)
 C_TEXT($aNSName1;$aNSName2;$aNSValue1;$aNSValue2)
 $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"/>

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.

 
PROPERTIES 

Product: 4D
Theme: XML DOM
Number: 861

The OK variable is changed by the commandThis command modifies the Error system variable

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D 2004

 
SEE ALSO 

DOM CLOSE XML
DOM SET XML DECLARATION