4D v14.3DOM Create XML element |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
DOM Create XML element
DOM Create XML element
The DOM Create XML element command creates a new element in the XML element elementRef in the path set by the xPath parameter and adds attributes to it if necessary. Pass the root element reference in elementRef (created, for example, using the DOM Create XML Ref command). In xPath, pass the access path in XPath notation of the element to create (see the “Use of XPath notation” paragraph in the Overview of XML DOM Commands section). If any path elements do not exist, they are created. It is possible to pass a simple item name directly in the xPath parameter in order to create a sub-item from the current item (see example 3). Note: If you have defined one or more namespaces for the tree set using elementRef (see the DOM Create XML Ref command), you must precede the xPath parameter with the namespace to be used (for example, “MyNameSpace:MyElement”). You can pass attribute/attribute value pairs (in the form of variables, fields or literal values) in the optional attrName and attrValue parameters. You can pass as many pairs as you want. The attrValue parameter can be of the text type or another type (Boolean, integer, real, date or time). If you pass a value other than text, 4D handles its conversion to text, according to the following principles:
The command returns the XML reference of the element created as a result. We want to create the following element: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <RootElement> <Elem1> <Elem2> <Elem3> </Elem3> <Elem3> </Elem3> </Elem2> </Elem1> </RootElement> To do so, simply write: C_TEXT(vRootRef;vElemRef) We want to create the following element (containing attributes): <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <RootElement> <Elem1> <Elem2> <Elem3 Font=Verdana Size=10> </Elem3> </Elem2> </Elem1> </RootElement> To do so, simply write: C_TEXT(vRootRef;vElemRef) We want to create and export the following structure: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <Root> <Elem1>Hello</Elem1> </Root> We want to use the syntax based on a simple item name. To do this, simply write: C_TEXT($root) 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. An error is generated when:
|
PROPERTIES
Product: 4D
HISTORY
Modified: 4D v11 SQL SEE ALSO
DOM Create XML element arrays ARTICLE USAGE
4D Language Reference ( 4D v11 SQL Release 6) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||