XML parsing
XML parsing is the process of converting XML data from its textual XML format to its hierarchical format.
You can let the Db2 database manager perform parsing implicitly, or you can call the XMLPARSE function to perform XML parsing explicitly.
Implicit XML parsing occurs in the following cases:
- When you pass data to the database server using a host variable
of type XML, or use a parameter marker of type XML
The database server does the parsing when it binds the value for the host variable or parameter marker for use in statement processing.
- When you assign a host variable, parameter marker, or SQL expression with a string data type (character, graphic or binary) to an XML column in an INSERT, UPDATE, DELETE, or MERGE statement. The parsing occurs when the Db2 database system implicitly adds an XMLPARSE function to the statement.
You perform explicit XML parsing when you invoke the XMLPARSE function on the input XML data. You can use the result of XMLPARSE in any context that accepts an XML data type. For example, you can assign the result to an XML column.
The XMLPARSE function takes a character or binary data type as
input. For embedded dynamic SQL applications, if the argument of the
XMLPARSE function is a parameter marker, it must be a typed marker.
For example:
INSERT INTO MYCUSTOMER (CID, INFO)
VALUES (?, xmlparse(document cast(? as clob(1k)) preserve whitespace))