xpath_short
Returns a short integer value, or the value zero if no match is found, or a match is found but the value is non-numeric.
Syntax
Python
from pyspark.sql import functions as sf
sf.xpath_short(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>1</b><b>2</b></a>',)], ['x'])
df.select(sf.xpath_short(df.x, sf.lit('sum(a/b)'))).show()
Output
+------------------------+
|xpath_short(x, sum(a/b))|
+------------------------+
| 3|
+------------------------+