xpath_string
Returns the text contents of the first xml node that matches the XPath expression.
Syntax
Python
from pyspark.sql import functions as sf
sf.xpath_string(xml, path)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| XML column or column name. |
|
| XPath expression. |
Examples
Python
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()
Output
+--------------------+
|xpath_string(x, a/c)|
+--------------------+
| cc|
+--------------------+