Skip to content

bigfunctions > xml_extract

xml_extract

Signature

xml_extract(xml, x_path)

Description

Returns content extracted from XML from given XPATH

Examples

1. Only one element for the xpath

select bigfunctions.eu.xml_extract("<customer><name>John Doe</name></customer>", "/customer/name")
select bigfunctions.us.xml_extract("<customer><name>John Doe</name></customer>", "/customer/name")
select bigfunctions.europe_west1.xml_extract("<customer><name>John Doe</name></customer>", "/customer/name")
+-----------------+
| extracted_value |
+-----------------+
| ["John Doe"]    |
+-----------------+

2. Multiple elements for the xpath

select bigfunctions.eu.xml_extract("<customer><name>John Doe</name><name>Jane Doe</name></customer>", "/customer/name")
select bigfunctions.us.xml_extract("<customer><name>John Doe</name><name>Jane Doe</name></customer>", "/customer/name")
select bigfunctions.europe_west1.xml_extract("<customer><name>John Doe</name><name>Jane Doe</name></customer>", "/customer/name")
+--------------------------+
| extracted_value          |
+--------------------------+
| ["John Doe", "Jane Doe"] |
+--------------------------+

3. Incorrect xpath

select bigfunctions.eu.xml_extract("<customer><name>John Doe</name></customer>", "/customer/na")
select bigfunctions.us.xml_extract("<customer><name>John Doe</name></customer>", "/customer/na")
select bigfunctions.europe_west1.xml_extract("<customer><name>John Doe</name></customer>", "/customer/na")
+-----------------+
| extracted_value |
+-----------------+
| null            |
+-----------------+