I am new to XML, but not SQL. I have data structured by our application provider as follows: I'm trying to load into a table:
<windowsets>
<windows>
<question>
<id Value="81b25d-9385-sk3" />
<displayname Value="Thermal Break" />
<answername Value="Yes" />
</question>
<question>
<id Value="73v32k-2743-fd9" />
<displayname Value="Panel Profile" />
<answername Value="Medium Stille" />
</question>
</windows>
</windowsets>
Through other posts here I found and got to creating:
select
t.x.value('(id [@Value]/text())[1]','varchar(100)') QuestionID,
t.x.value('(displayname [@Value]/text())[1]','varchar(255)') DisplayName,
t.x.value('(answername [@Value]/text())[1]','varchar(255)') AnswerName
from @xmlData.nodes('//windowsets/windows/question') as T(X)
But it returns nulls for all columns, and I assume that since it expects a format:
<displayname>Panel Profile</displayname>
So, being a newbie to XML and everything I did a search, I don’t understand how to change the code to pull it out when the value is buried in node (not even sure of the correct terminology, I'm so new).
Thank you for your help!
Akenn source
share