I like shred XML document from SQL SERVER 2005 XML datatype column to relational format with the NODES method.
My XML document may contain three or more nested elements like COMPLEX-> OBJECT-> SUBOBJECT...
With nodes method i can extract nodes element attributes and parent element attributes, as shown below .
select
Colx.query('data(../@objectid)') as objectNumber,
Colx.value('@subobjectID', 'int') as subobjectid
from Complex_XMLTA cross apply XMLdata.nodes('declare default element namespace "XMLTA"; /complex/object/subobject') as Tabx(Colx)
My question is, how to get ancestors for selected node in same manner?
My XML document may contain three or more nested elements like COMPLEX-> OBJECT-> SUBOBJECT...
With nodes method i can extract nodes element attributes and parent element attributes, as shown below .
select
Colx.query('data(../@objectid)') as objectNumber,
Colx.value('@subobjectID', 'int') as subobjectid
from Complex_XMLTA cross apply XMLdata.nodes('declare default element namespace "XMLTA"; /complex/object/subobject') as Tabx(Colx)
My question is, how to get ancestors for selected node in same manner?