XMLELEMENT()

Scalar. Constructs an XML element tree.

Syntax

XMLELEMENT( [NAME] "name" [, namespace] [, xmlattribute] { [, { xmlpi | xmlcomment | content } ] [, ...] } )
Parameters

name

The name of the element. Must conform to XML name conventions including XML name spaces.

namespace

Defines a name space for this element. See namespace for more information.

xmlattribute

Defines an XML attribute. See XMLATTRIBUTES() for more information.

xmlpi

An XML processing instruction. See XMLPI() for more information.

xmlcomment

A comment. See XMLCOMMENT() for more information.

content

Content for the element.

Data Types

Return

name

content

XML

String

String

XML

namespace

XMLNAMESPACES( { uri AS prefix | DEFAULT uri | NO DEFAULT } [, ...] )
Parameters

uri

The URI of an XML name space.

prefix

A literal specifying the prefix for the name space. Each prefix must be unique for each call to this function.

Data Types

Return

uri

prefix

String

String

String

See Also

Example

The following example shows the construction of an XML element tree:

SELECT
   XMLELEMENT("order",
    XMLELEMENT("orderid", orders.orderid),
    XMLELEMENT("billing",
      XMLELEMENT("name", orders.customername),
      XMLELEMENT("city", orders.customerCity),
      XMLELEMENT("state", orders.customerState)
    )
   ) 
FROM Orders;