Semi-structured Data Functions (Extraction)
Extracts an XML element object (often referred to as simply a “tag”) from a content of outer XML element object by the name of the tag and its instance number (counting from 0):
If any argument of XMLGET is NULL, the result is NULL.
If the tag instance is not found, the result is similarly NULL.
XMLGET( <type> , <tag_name> , [ <instance_num> ] )
instance_numcan be omitted, in which case the default value 0 is used.
The result of XMLGET is not the content of the tag, but the tag itself (an object):
To extract attribute values, use
To extract the content, use
To extract the tag name, use
Positions of the inner tags in the content can be obtained by using
GET(tag, 'inner-tag-name'); if the content contains multiple elements, it will be represented as an array.
SELECT GET(XMLGET(xml, 'dt', 2), '$') as "Term", GET(XMLGET(xml, 'dd', 2), '$') as "Definition" FROM dictionary;