XMLGET

functionsupportedCore SQL functions

docs.snowflake.com ↗

Semi-structured and structured data functions

Extracts an XML element object (often referred to as simply a tag) from the content of the outer XML element based on the name and instance number of the specified tag. (Note that an XML tag is not the same as a Snowflake data governance tag.)

Syntax

supportedpartialnot supportednot scored

XMLGET( <expression> , <tag_name> [ , <instance_number> ] )

Parameters

NameRequiredDescription
expressionrequiredThe expression from which to extract the element. The expression must evaluate to an OBJECT (or a VARIANT containing an OBJECT). The OBJECT must contain valid XML in the internal format that Snowflake supports. Typically, that means that the OBJECT was produced by one of the following: Calling the PARSE_XML function. Loading the data (e.g. via the COPY INTO <table> command) and specifying that the data is in XML format. The XMLGET function does not operate directly on a VARCHAR expression even if that VARCHAR contains valid XML text.
tag_namerequiredThe name of an XML tag stored in the expression.
instance_numberrequiredIf the XML contains multiple instances of tag_name, then use instance_number to specify which instance to retrieve. Like an array index, the instance_number is 0-based, not 1-based. instance_number can be omitted, in which case the default value 0 is used.

Returns

The data type of the returned value is OBJECT. The function returns NULL in the following cases: - If any argument of XMLGET is NULL. - If the tag instance isn’t found. See the Usage Notes for more details.

Usage notes

See also

Referenced by