XMLELEMENT

2026-02-03 08:48:37  Updated

Purpose

XMLELEMENT() 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

Parameter Description
ENTITYESCAPING | NOENTITYESCAPING Optional. Specifies whether to force escape the name and content of the element. We recommend that you use the default value ENTITYESCAPING.
NAME Optional. The keyword that specifies the root element name to a literal identifier. The value after NAME is the literal identifier.
EVALNAME The keyword that specifies the root element name to an expression that evaluates to a literal identifier. The expression after EVALNAME is the expression to evaluate.
identifier The literal identifier that names the root element.
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 data, such as XMLELEMENT or XMLAGG.
XML_attributes_clause Optional. The expression that specifies element attributes. For more information, see XMLATTRIBUTES.
c_alias The alias of element content, which is a string literal.

Return type

The return type is XMLType.

Examples

The following example constructs an XML element named Emp with the content being value.

obclient> SELECT XMLELEMENT(NAME "Emp", 'value') FROM DUAL;
+-------------------------------+
| XMLELEMENT(NAME"EMP",'VALUE') |
+-------------------------------+
| <Emp>value</Emp>
             |
+-------------------------------+
1 row in set

Contact Us