1

I have following XML to parse in SQL Server 2008

<Root>
  <Document>
    <Body>
      <Component>
      </Component>
    </Body>
  </Document>
</Root>

I want to retrieve all the <Component> tags in my xml, the issue is that <Document> tag at times might not come, Hence my xpath query of (root/document/body) won't work. Is there way I can get all <Component> tags irrespective of presence of <Document> tag?

1 Answer 1

2

You could always use an XPath query of

//component

to get all <component> elements in your entire document - no matter where they are and what other tags there are around it

Sign up to request clarification or add additional context in comments.

1 Comment

Or like this if you want to be a little bit more specific. /Root//Body/Component

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.