pyspark.sql.functions.xpath_string#
- pyspark.sql.functions.xpath_string(xml, path)[source]#
Returns the text contents of the first xml node that matches the XPath expression.
New in version 3.5.0.
See also
pyspark.sql.functions.from_xml()pyspark.sql.functions.schema_of_xml()pyspark.sql.functions.to_xml()pyspark.sql.functions.xpath()pyspark.sql.functions.xpath_boolean()pyspark.sql.functions.xpath_double()pyspark.sql.functions.xpath_float()pyspark.sql.functions.xpath_int()pyspark.sql.functions.xpath_long()pyspark.sql.functions.xpath_number()pyspark.sql.functions.xpath_short()
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| +--------------------+