snowflake.snowpark.functions.xpath_string

snowflake.snowpark.functions.xpath_string(col: Union[Column, str], path: str) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.37.0/src/snowflake/snowpark/functions.py#L11805-L11832)

Extracts the first value from an XML column using an XPath expression as a string.

Returns NULL if no matches are found.

Parameters:
  • col – Column containing XML data

  • path – XPath expression string

Example:

>>> df = session.create_dataframe([['<root><a>1</a><a>2</a></root>']], schema=['xml'])
>>> df.select(xpath_string('xml', '//a/text()').alias('result')).collect()
[Row(RESULT='1')]
Copy
Language: English