Partager via


xpath_boolean

Retourne true si l’expression XPath prend la valeur true ou si un nœud correspondant est trouvé.

Syntaxe

from pyspark.sql import functions as sf

sf.xpath_boolean(xml, path)

Paramètres

Paramètre Type Descriptif
xml pyspark.sql.Column ou str Nom de colonne ou de colonne XML.
path pyspark.sql.Column ou str Expression XPath.

Examples

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