Aller au contenu principal

xpath_short

Renvoie une valeur entière courte, ou zéro si aucune correspondance n'est trouvée, ou si une correspondance est trouvée mais que la valeur n'est pas numérique.

Syntaxe

Python
from pyspark.sql import functions as sf

sf.xpath_short(xml, path)

parameter

parameter

Type

Description

xml

pyspark.sql.Column ou str

Colonne XML ou nom de colonne.

path

pyspark.sql.Column ou str

Expression XPath.

parameter

Type

Description

xml

pyspark.sql.Column ou str

Colonne XML ou nom de colonne.

path

pyspark.sql.Column ou str

Expression XPath.

Exemples

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|
+------------------------+