pyspark.sql.functions.xpath_string

pyspark.sql.functions.xpath_string(xml: ColumnOrName, path: ColumnOrName) → pyspark.sql.column.Column[source]

Returns the text contents of the first xml node that matches the XPath expression.

New in version 3.5.0.

Examples

>>> df = spark.createDataFrame([('<a><b>b</b><c>cc</c></a>',)], ['x'])
>>> df.select(xpath_string(df.x, lit('a/c')).alias('r')).collect()
[Row(r='cc')]