<<<<<<< HEAD xmlcdata | H2 | SQLDoc
Skip to main content

xmlcdata

1. XMLCDATA Function

======= xmlcdata | H2 Function | SQLDoc

xmlcdata

1. XMLCDATA Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The XMLCDATA function in H2 database is used to wrap a given string inside a CDATA section in XML format.

2. Syntax

The syntax for the XMLCDATA function in H2 database is as follows:

XMLCDATA(string)
<<<<<<< HEAD

Arguments

=======

Arguments

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be
  • string: The string that needs to be wrapped inside a CDATA section. It should be a valid string value.

Return

  • The XMLCDATA function returns the input string wrapped inside a CDATA section in XML format.

3. Notes

  • The XMLCDATA function in H2 database is specifically designed for generating XML content and should be used only in such scenarios.
  • The output of the XMLCDATA function will be a string enclosed within <![CDATA[ ... ]]> tags, indicating a CDATA section.
  • If the input string contains any special characters like <, >, &, etc., the XMLCDATA function will handle them properly, ensuring valid XML output.

4. Examples

Here are a few examples demonstrating the usage of the XMLCDATA function in H2 database:

Example 1 - Wrapping a string inside a CDATA section:

SELECT XMLCDATA('This is some <sample> text & data') AS cdata;

Output:

cdata
---------------------------------------
<![CDATA[This is some <sample> text & data]]>

Example 2 - Using XMLCDATA function in an XML query:

SELECT XMLELEMENT(NAME "book", XMLCDATA('This is some <sample> text & data')) AS xml_data;

Output:

xml_data
-------------------------------------
<book><![CDATA[This is some <sample> text & data]]></book>
  • XMLELEMENT - Create an XML element
  • XMLATTRIBUTES - Add attributes to an XML element