Purpose
This function generates an XML element with the specified name, attributes, and content.
Syntax
XMLELEMENT ( [ ENTITYESCAPING | NOENTITYESCAPING ]
{ ( [ NAME ] identifier ) | ( EVALNAME value_expr ) }
[ , XML_attributes_clause ]
[ , value_expr [ [ AS ] c_alias ]]...
)
Parameters
| Field | Description |
|---|---|
| ENTITYESCAPING | NOENTITYESCAPING | Optional. Specifies whether to force escaping of the element's name and content. We recommend that you use the default behavior ENTITYESCAPING of expressions. |
| NAME | Optional. Specifies the root element name as a literal identifier. NAME indicates that the value following it is the identifier. |
| EVALNAME | Optional. Specifies the root element name as a computed result of a string. EVALNAME indicates that the value following it needs to be computed to obtain the result. |
| identifier | The string type tag name. |
| value_expr | The element value expression. This parameter can be another element or text. If it is another element, it can be an XMLType column or an expression that generates XMLType, such as XMLELEMENT or XMLAGG. |
| XML_attributes_clause | Optional. Specifies the element attribute expression. For more information, see XMLATTRIBUTES. |
| c_alias | The string type content alias. |
Return type
XMLType.
Examples
The following example creates an XML element named Emp with the content value.
obclient> SELECT XMLELEMENT(NAME "Emp", 'value') FROM DUAL;
+-------------------------------+
| XMLELEMENT(NAME"EMP",'VALUE') |
+-------------------------------+
| <Emp>value</Emp>
|
+-------------------------------+
1 row in set
