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/parse_xml below:

Website Navigation


PARSE_XML | Snowflake Documentation

Categories:

Semi-structured and structured data functions (Parsing)

PARSE_XML

Interprets an input string as an XML document, producing an OBJECT value. If the input is NULL, the output is NULL.

See also:

CHECK_XML, TO_XML, XMLGET

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

Copy

PARSE_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

A Boolean expression that specifies whether or not the function should attempt to convert numeric and Boolean values in string_containing_xml to Snowflake data types. (For details about this conversion, see Usage Notes below.)

Default: FALSE

Returns

The data type of the returned value is OBJECT. The OBJECT contains an internal representation of the XML.

Usage notes Examples

The following example demonstrates how to use the PARSE_XML function to convert a string of XML to an OBJECT that can be inserted into an OBJECT column:

CREATE OR REPLACE TABLE xtab (v OBJECT);

INSERT INTO xtab SELECT PARSE_XML(column1) AS v
  FROM VALUES ('<a/>'), ('<a attr="123">text</a>'), ('<a><b>X</b><b>Y</b></a>');

SELECT * FROM xtab;

Copy

+------------------------+
| V                      |
|------------------------|
| <a></a>                |
| <a attr="123">text</a> |
| <a>                    |
|   <b>X</b>             |
|   <b>Y</b>             |
| </a>                   |
+------------------------+

The following example demonstrates the differences between using and disabling the conversion of numeric values. In this example, when the conversion isn’t disabled, the function interprets a number in scientific notation as a DOUBLE.

SELECT PARSE_XML('<test>22257e111</test>'), PARSE_XML('<test>22257e111</test>', TRUE);

Copy

+-------------------------------------+-------------------------------------------+
| PARSE_XML('<TEST>22257E111</TEST>') | PARSE_XML('<TEST>22257E111</TEST>', TRUE) |
|-------------------------------------+-------------------------------------------|
| <test>2.225700000000000e+115</test> | <test>22257e111</test>                    |
+-------------------------------------+-------------------------------------------+

The following example demonstrates how to specify the arguments to the function by name:

SELECT PARSE_XML(STR => '<test>22257e111</test>', DISABLE_AUTO_CONVERT => TRUE);

Copy

+--------------------------------------------------------------------------+
| PARSE_XML(STR => '<TEST>22257E111</TEST>', DISABLE_AUTO_CONVERT => TRUE) |
|--------------------------------------------------------------------------|
| <test>22257e111</test>                                                   |
+--------------------------------------------------------------------------+

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