declare @exp XML set @exp= N'<SpItem> <SPId>1</SPId> <NName>ab</NName> <Expr> <Oprt> </Oprt> <Nr>10</Nr> <Oprt>+</Oprt> <Data> <Type>Mc</Type> <Id>10</Id> <Value>Mc Value</Value> </Data> <Oprt>+</Oprt> <Data> <Type>DataElement</Type> <Id>10</Id> <Value>Mc Value</Value> </Data> <Oprt>*</Oprt> <SPItem> <SPId></SPId> <NName>My SPad</NName> <Expr> <Oprt> </Oprt> <Data> <Type>Metric</Type> <Id>10</Id> <Value>Mc Value</Value> </Data> </Expr> </SPItem> </Expr> </SpItem>'
select col.value('(Oprt/text())[1]','varchar(50)'), col.value('(text())[1]','varchar(50)') from @exp.nodes('//Expr') as tab(col) cross apply col.nodes('Data') as dtype(dt)
SPId NName Oprt Nr Type Inner SPId 1 ab 10 1 ab + 10 DataElement 1 ab + 10 Mc 1 ab * 1 ab + 10 Metric 2
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)