Partager via


xpath_string

Retourne le contenu du texte du premier nœud xml qui correspond à l’expression XPath.

Syntaxe

from pyspark.sql import functions as sf

sf.xpath_string(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>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|
+--------------------+