I have a table in SQL Server in which one of the columns is an XML Datatype. There are other columns in the table that are not XML. Here is an example of the XML that is stored in the column:
<AdultAsthma>
<Group>
<Question text="Act Score:" ForeColor="Green" />
<Controls>
<Control type="Label" id="txtScore" text="Enter ACT Score:" ForeColor="Black" />
<Control type="TextBox" id="txtActScore" Answer="" />
</Controls>
</Group>
</AdultAsthma>
What I want is a query that matches some values on the other columns in the table and for those columns that match, I want to get the text attribute from the Question Node and the Answer attribute from the Control node. Can someone help me with this?
EDIT
What needs to be changed if I have more than one Group node? In this scenerio, I would want the text of each question and the answer to go along with each question. See below:
<AdultAsthma>
<Group>
<Question text="Act Score:" ForeColor="Green" />
<Controls>
<Control type="Label" id="txtScore" text="Enter ACT Score:" ForeColor="Black" />
<Control type="TextBox" id="txtActScore" Answer="" />
</Controls>
</Group>
<Group>
<Question text="Do You Have Asthma?:" ForeColor="Black" />
<Controls>
<Control type="RadioButton" id="rbHaveAsthmaYes" text="Yes" GroupName="Diagnosed" ForeColor="Black" Answer="False" />
<Control type="RadioButton" id="rbHaveAsthmaNo" text="No" GroupName="Diagnosed" ForeColor="Black" Answer="False" />
</Controls>
</Group>
</AdultAsthma>