Example: Using XMLEXTRACT to Evaluate a Query Against an XML Instance

Teradata Vantageā„¢ XML Data Type

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1140-162K

In this example, the XPath expression (in bold) is extracting the Address elements in the XML documents for the customer named John Hancock.

SELECT customerXML.XMLEXTRACT('/Customer[Name="John Hancock"]/Address', '')
FROM customer
WHERE customerID = 1;

Query result:

customerXML.XMLEXTRACT('/Customer[Name="John Hancock"]/Address', '')
--------------------------------------------------------------------
<Address>100 1st Street, San Francisco, CA 94118</Address>