XMLParser Example 5: Grandparent, Parent, and Child Nodes - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example uses the Nodes and Ancestors arguments to show the hierarchy of grandparent, parent, and child nodes.

Input

xml_input2
xid xml
1 <School name="UCBerkeley">

: <Dept ID="CS" name="Computer Science">

: <Class A="sophomore" B="Senior">

: <Year>

: <Student>Harry</Student>

: <Grade>A+</Grade>

: </Year>

: </Class>

: </Dept>

: </School>

SQL Call

SELECT * FROM XMLParser (
  ON xml_input2
  USING
  TextColumn ('xml')
  Nodes ('Class:{A,B}/Year/Student', 'Year/Grade')
  Ancestor ('School/Dept')
  Accumulate ('xid')
) AS dt;

Output

xid out_nodeid out_grandparent_node out_parent_node Class:A Class:B Student Grade
1 1 Class Year sophomore Senior Harry A+