Querying XML using OPENXML WITH - mixed attribute-centric and element-centric
Posted on 2011-09-29
I have an XML structure that is mixed - both attribute-centric and element-centric. For example:
<stat num="33" type="days_attended"/>
<stat num="12" type="referrals"/>
I'm using element-centric to grab the data. For example:
FROM OPENXML (@mydata, //xml-tree/stats',2)
year int 'year',
days_attended int ???,
referrals int ???
How would I grab the value of "num" based upon the type = "days_attended" for example.
I know I can grab num using something like:
num int 'stat/@num'
...But how would I know which num it is. I want to be able to grab that num value and call the column by the type value (days_attended for example).
Thanks in advance!