I have an XML doc like this:
DROP TABLE #temp
create table #temp (xml_data xml)
insert into #temp (xml_data) values
('<UPDATE><ENTITY DN="test"><ATTRIBUTE N="test name" V="test value" /> </ENTITY></UPDATE>')
select C.value('@DN', 'varchar(max)') as [ENTITY.DN]
,C.value('@N', 'varchar(max)') as [ATTRIBUTE.N]
,C.value('@V', 'varchar(max)') as [ATTRIBUTE.V]
from #temp cross apply
#temp.xml_data.nodes('UPDATE/ENTITY') as X(C)
My output ends up like this:
test | NULL | NULL
I'd like to see:
test | test name | test value
Any thoughts on how I've configured this incorrectly?
DROP TABLE #temp create table #temp (xml_data xml) insert into #temp (xml_data) values ('<UPDATE><ENTITY DN="test"><ATTRIBUTE N="test name" V="test value" /></ENTITY></UPDATE>') select C.value('@DN', 'varchar(max)') as [ENTITY.DN] ,r.value('@N', 'varchar(max)') as [ATTRIBUTE.N] ,r.value('@V', 'varchar(max)') as [ATTRIBUTE.V] from #temp cross apply #temp.xml_data.nodes('UPDATE/ENTITY') as X(C) cross apply #temp.xml_data.nodes('UPDATE/ENTITY/ATTRIBUTE') as Y(r)