
The XMLPARSE function parses the arguments as an XML document and returns an XML value.
.-STRIP WHITESPACE----. >>-XMLPARSE--(--DOCUMENT--string-expression--+---------------------+--)->< '-PRESERVE WHITESPACE-'
The result of the function is XML. If the result of string-expression can be null, the result can be null; if the result of string-expression is null, the result is the null value. The CCSID of the result is determined from string-expression. If string-expression has a CCSID of 65535, the value from the SQL_XML_DATA_CCSID QAQQINI option is used.
The input string may contain an XML declaration that identifies the encoding of the characters in the XML document. The encoding in the XML declaration must match the encoding of the string-expression.
Example 1: Insert an XML document into the EMP table and preserve the whitespace in the original XML document.
INSERT INTO EMP (ID, XVALUE) VALUES(1001,
XMLPARSE(DOCUMENT '<a xml:space=''preserve''> <b> <c>c</c>b </b> </a>'
PRESERVE WHITESPACE))
XMLPARSE will
treat the value for the insert statement as equivalent to the following
value:<a xml:space='preserve'> <b> <c>c</c>b </b> </a>
Example 2: Insert an XML document into the EMP table and strip the whitespace in the original XML document.
INSERT INTO EMP (ID, XVALUE) VALUES(1001,
XMLPARSE(DOCUMENT
'<a xml:space=''preserve''> <b xml:space=''default''> <c>c</c>b </b> </a>'
STRIP WHITESPACE))
XMLPARSE will treat
the value for the insert statement as equivalent to the following
value:<a xml:space='preserve'> <b xml:space='default'><c>c</c>b </b> </a>
