XPath 式に一致する最初の xml ノードのテキストコンテンツを返します。
構文
from pyspark.sql import functions as sf
sf.xpath_string(xml, path)
パラメーター
| パラメーター | タイプ | Description |
|---|---|---|
xml |
pyspark.sql.Column または str |
XML 列または列名。 |
path |
pyspark.sql.Column または str |
XPath 式。 |
例示
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|
+--------------------+