如果 XPath 表达式的计算结果为 true,或者找到匹配的节点,则返回 true。
Syntax
from pyspark.sql import functions as sf
sf.xpath_boolean(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>1</b></a>',)], ['x'])
df.select(sf.xpath_boolean(df.x, sf.lit('a/b'))).show()
+---------------------+
|xpath_boolean(x, a/b)|
+---------------------+
| true|
+---------------------+