メインコンテンツまでスキップ

xpath_string

XPath 式に一致する最初の XML ノードのテキスト コンテンツを返します。

構文

Python
from pyspark.sql import functions as sf

sf.xpath_string(xml, path)

パラメーター

パラメーター

Type

説明

xml

pyspark.sql.Column または文字列

XML 列または列名。

path

pyspark.sql.Column または文字列

XPath 式。

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