I have a table called XMLTest, with a single column called Val with XML datatype
create table XMLTest(Val XML)
Into this table I read this data:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
<SOAP-ENV:Body>
<ns0:getInterestAndExchangeRatesResponse xmlns:ns0="http://swea.riksbank.se/xsd">
<return xmlns="">
<datefrom xmlns="">2020-03-25</datefrom>
<dateto xmlns="">2020-03-26</dateto>
<groups xmlns="">
<groupid xmlns="">130</groupid>
<groupname xmlns="">Currencies against Swedish kronor</groupname>
<series xmlns="">
<seriesid xmlns="">SEKEURPMI</seriesid>
<seriesname xmlns="">1 EUR</seriesname>
<unit xmlns="">1.0E0</unit>
<resultrows xmlns="">
<date xmlns="">2020-03-25</date>
<period xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns="" ns1:nil="true" />
<min xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns="" ns1:nil="true" />
<average xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns="" ns1:nil="true" />
<max xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns="" ns1:nil="true" />
<ultimo xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" xmlns="" ns1:nil="true" />
<value xmlns="">1.08823E1</value>
</resultrows>
</series>
</groups>
</return>
</ns0:getInterestAndExchangeRatesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So the final result is all of this data in a single column & single row. I've tried to extract the relevant data from this XML. I'm interested in seriesid & its value. So the final output would be:
seriesid | value
SEKEURPMI| 1.08823E1
and ultimately there will be multiple so the results would be more like:
seriesid | value
SEKEURPMI| 1.08823E1
SEKUSDPMI| 1.3823E1
.... | ...
However I'm having problems creating valid query to get this information. None of the solutions I've been trying work with mine because I'm querying directly from a table. I've been trying to implement this solution: How can I save data from xml to sql 2008? but I don't seem to be able to apply the same technique when querying from a table.