Purpose
XMLELEMENT() generates an XML element with the given name, attributes, and content.
Syntax
XMLELEMENT ( [ ENTITYESCAPING | NOENTITYESCAPING ]
{ ( [ NAME ] identifier ) | ( EVALNAME value_expr ) }
[ , XML_attributes_clause ]
[ , value_expr [ [ AS ] c_alias ]]...
)
Parameters
| Parameter | Description |
|---|---|
| ENTITYESCAPING | NOENTITYESCAPING | Specifies whether to escape the name and content of the element. This parameter is optional. If you do not specify it, escaping is required by default. |
| NAME | The keyword that specifies the root element name to a literal identifier. This parameter is optional. |
| EVALNAME | The keyword that specifies the root element name to an expression that evaluates to a literal identifier. |
| identifier | The literal identifier that names the root element. |
| value_expr | The element value expression, which can be another element, such as an XMLType expression generated by XMLELEMENT or XMLAGG, or text. |
| XML_attributes_clause | The expression that specifies an element attribute. For more information, see XMLATTRIBUTES. This parameter is optional. |
| c_alias | The alias of element content, which is a string literal. |
Return type
The return type is CLOB.
Example
Construct an XML element named Emp whose content is value.
obclient> SELECT XMLELEMENT(NAME "Emp", 'value') FROM DUAL;
+-------------------------------+
| XMLELEMENT(NAME"EMP",'VALUE') |
+-------------------------------+
| <Emp>value</Emp> |
+-------------------------------+
1 row in set