XMLELEMENT
The XMLELEMENT function creates an XML node with an optional XML attributes node.
Syntax
XMLELEMENT ( NAME <XML_element_name>
[ , <XML_namespace_declaration> ] [ , <XML_attributes> ]
[ { , <XML_element_content> }... [ OPTION <XML_content_option> ] ]
[ <XML_returning_clause> ] )
Remarks
|
•
|
The first argument, XML_element_name, is the name of the XML node. It can be escaped if it contains certain characters. For details, see Identifier Escaping. |
|
•
|
The optional second argument, XML_namespace_declaration, is the XMLNAMESPACE function. |
|
•
|
The optional third argument, XML_attributes, is the XMLATTRIBUTES function. |
|
•
|
The optional fourth argument, XML_element_content, is the content of the XML node, which can be an XML, numeric, or character type. |
|
•
|
If XML_element_content evaluates to a character literal, it is escaped. For details, see Text Escaping. |
Example
SELECT XMLELEMENT (name Details, XMLATTRIBUTES (ProductID AS product),
XMLELEMENT (name orderno, OrderID),
XMLELEMENT (name status, Status),
XMLELEMENT (name price, UnitPrice)) myOutput
FROM /shared/examples/ds_orders/orderdetails
WHERE ProductID < 20