I am trying to save data values into a table so that I can use them but can't get my head around it. I am currently running SQL Server 2012. How do I read soap XML which is saved in @x
variable?
declare @x xml
set @x = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ListResponse xmlns="http://api.com">
<ListResult>
<API>
<ID>1565</ID>
<Email>jd@dj.com</Email>
<Type>Unknown</Type>
<Notes />
</API>
</ListResult>
</ListResponse>
</soap:Body>
</soap:Envelope>'
This is what I come up but it is only returning data in a single column with no way of knowing which data belongs to which column
select convert(varchar, n.c.value('.', 'varchar(max)'))
from @X.nodes('//text()[1]') n(c)
1565
jd@dj.com
Unknown
Data is coming in column format where as i wants in row with each API returns. currently only 1 API return what if more then 1 ?