I'm trying to analyse a quite complex (and unfortunately mainly undocumented) XML document via SA's OpenXML() operator.

While it's easy to return all nodes with a particular value, I need to get to know their according absolute pathes.

Is there a way to do so, except recursively accessing the parent node? (With DOM, I would use the getNodePath() function.)

The XPath 3 path() function would help here but seems to be unsupported with v16:

select *
from openxml(using value varXml, '//*')
 with
 (ID int  '@mp:id',
  ElementName long varchar '@mp:localname',
  ParentElementName long varchar '../@mp:localname',
  -- I'd prefer not to need to extend that to further levels...
  GrandParentElementName long varchar '../../@mp:localname',
  ElementText long varchar 'text()',
  -- ElementPath long varchar 'path()', -- not supported
  ElementXmlText long varchar '@mp:xmltext') DT
where ElementText = <desired value="">;

asked 03 Mar, 09:44

Volker%20Barth's gravatar image

Volker Barth
29.6k293444650
accept rate: 32%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×194
×19
×11

question asked: 03 Mar, 09:44

question was seen: 117 times

last updated: 03 Mar, 09:44