Example: Using XMLEXTRACT to Evaluate a Query Against an XML Instance - Analytics Database - Teradata Vantage

XML Data Type

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
tkc1628112506748.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dgs1472251600184
lifecycle
latest
Product Category
Teradata Vantageā„¢

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>