A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/check_xml below:

Website Navigation


CHECK_XML | Snowflake Documentation

Categories:

Semi-structured and structured data functions (Parsing)

CHECK_XML

Checks the validity of an XML document. If the input string is NULL or a valid XML document, the output is NULL. In case of an XML parsing error, the output string contains the error message.

See also:

PARSE_XML, TO_XML, XMLGET

Syntax
CHECK_XML( <string_containing_xml> [ , <disable_auto_convert> ] )

Copy

CHECK_XML( STR => <string_containing_xml>
  [ , DISABLE_AUTO_CONVERT => <disable_auto_convert> ] )

Copy

Arguments

Required:

string_containing_xml . OR . STR => string_containing_xml

Specify an expression that evaluates to a VARCHAR value that contains valid XML.

Optional:

disable_auto_convert . OR . DISABLE_AUTO_CONVERT => disable_auto_convert

Specify the same value that you pass to the PARSE_XML function.

Default: FALSE

Returns

The data type of the returned value is VARCHAR.

Usage notes Examples

The following examples use the CHECK_XML function.

Show the output of the function when the XML is valid
SELECT CHECK_XML('<name> Valid </name>');

Copy

+-----------------------------------+
| CHECK_XML('<NAME> VALID </NAME>') |
|-----------------------------------|
| NULL                              |
+-----------------------------------+
Show the output of the function when the XML is invalid
SELECT CHECK_XML('<name> Invalid </WRONG_CLOSING_TAG>');

Copy

+--------------------------------------------------+
| CHECK_XML('<NAME> INVALID </WRONG_CLOSING_TAG>') |
|--------------------------------------------------|
| no opening tag for </WRONG_CLOSING_TAG>, pos 35  |
+--------------------------------------------------+
Locate records with invalid XML
SELECT xml_str, CHECK_XML(xml_str)
  FROM my_table
  WHERE CHECK_XML(xml_str) IS NOT NULL;

Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4