I am trying to get ancestor tags name using open xml in sql server 2008. Here is what i have tried so far:
SELECT * FROM OPENXML(@idoc, '/Envelope/Body/*/TagParent/Tag')
WITH (
[Name] varchar(max) '../@mp:parentLocalName'
)
I need to get the name of the 3rd tag,*. I can successfully run parentlocalname and localname, but nothing works for parent’s parent.
I have tried many varients of above, it just errors out saying namespace mp is not defined. Is it even possible to fetch that name.
This is a little hacky, but should work, where
../../.is the path to whichever parent you’re looking for.Working example.