pyspark.sql.functions.xpath_string#

pyspark.sql.functions.xpath_string(xml, path)[source]#

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

New in version 3.5.0.

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([('<a><b>b</b><c>cc</c></a>',)], ['x'])
>>> df.select(sf.xpath_string(df.x, sf.lit('a/c'))).show()
+--------------------+
|xpath_string(x, a/c)|
+--------------------+
|                  cc|
+--------------------+