I have been working with an XML document, but never bothered looking at the DTD.
Thankfully today I found I was missing some patterns.
And, so need to quickly understand how to perform Xpath OR matching; I guess it is called XPath Union.
Sample XML Fragment
Here is a sample XML fragment.
We issue XPath and use commas (,) to separate each path.
Qualifier Hard coded
select [item] = x.y.query('.') , [parent] = x.y.query('..') from @basket.nodes ( ' /basket/item/department[contains(., "produce")] , /basket/item/department[.="hardware"] ' ) as x(y)
Qualifier SQL Variable
declare @type nvarchar(60) declare @color nvarchar(60) set @type = 'pears' set @color = 'red' select [item] = x.y.query('.') , [parent] = x.y.query('..') from @basket.nodes ( ' /basket/item/type[.=sql:variable("@type")] , /basket/item/color[.=sql:variable("@color")] ' ) as x(y)