Q:

Parsing XML with T-SQL returns anything

I wrote a web service and a webmethod it returns list of my class(DOVIZ_RETURN) on xml format like this:
 <?xml version="1.0" encoding="utf-8"?>
<ArrayOfDOVIZ_RETURN xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
    <DOVIZ_RETURN>
        <dovizAdi>AMERİKAN DOLARI</dovizAdi>
        <dovizKodu>USD</dovizKodu>
        <dovizAlis>1.7928</dovizAlis>
        <dovizSatis>1.8014</dovizSatis>
    </DOVIZ_RETURN>
    <DOVIZ_RETURN>
        <dovizAdi>KANADA DOLARI</dovizAdi>
        <dovizKodu>CAD</dovizKodu>
        <dovizAlis>1.8321</dovizAlis>
        <dovizSatis>1.8404</dovizSatis>
    </DOVIZ_RETURN>
</ArrayOfDOVIZ_RETURN>

and ı am calling this service with a stored procedure sucessfully. I am getting this xml. But when ı parse this xml with sql below, it returns any rows just returns column titles; Look below please:
ALTER PROCEDURE GET_DOVIZ_KUR_RESULT_FROM_SERVIS

AS
    declare @obj int
    declare @servisUrl varchar(200)
    declare @response xml

    SET @servisUrl='http://localhost/DovizKurTestApp/DovizKurService.asmx/GET_DOVIZ_KUR'

    EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
    EXEC sp_OAMethod @obj,'Open',NULL,'GET',@servisUrl,false
    EXEC sp_OAMethod @obj,'send'
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUT

    create table #DOVIZ_KUR (dovizKurList xml)
    insert into #DOVIZ_KUR select @response 

    SELECT
    a.b.value('dovizAdi[1]', 'Varchar(100)') DovizAdi,
    a.b.value('dovizKodu[1]', 'Varchar(100)') DovizKodu,
    a.b.value('dovizAlis[1]', 'Varchar(100)') DovizAlis,
    a.b.value('dovizSatis[1]', 'Varchar(100)') DovizSatis
    FROM #DOVIZ_KUR
    CROSS APPLY dovizKurList.nodes('/ArrayOfDOVIZ_RETURN/DOVIZ_RETURN') AS a(b)

    EXEC sp_OADestroy @obj

RETURN

what is wrong here?

A:

The reason for this was due to the fact that namespaces were included in the XML.
You can try this
SELECT  
    a.b.value('declare namespace MI="http://tempuri.org/"; MI:dovizAdi[1]', 'Varchar(100)') DovizAdi, 
    a.b.value('declare namespace MI="http://tempuri.org/"; MI:dovizKodu[1]', 'Varchar(100)') DovizKodu, 
    a.b.value('declare namespace MI="http://tempuri.org/"; MI:dovizAlis[1]', 'Varchar(100)') DovizAlis, 
    a.b.value('declare namespace MI="http://tempuri.org/"; MI:dovizSatis[1]', 'Varchar(100)') DovizSatis 
FROM @DOVIZ_KUR d
    CROSS APPLY dovizKurList.nodes('
    declare namespace MI="http://tempuri.org/";
    /MI:ArrayOfDOVIZ_RETURN/MI:DOVIZ_RETURN') AS a(b)

OR Even better
;WITH XMLNAMESPACES('http://tempuri.org/' as MI)
SELECT  
    a.b.value('MI:dovizAdi[1]', 'Varchar(100)') DovizAdi, 
    a.b.value('MI:dovizKodu[1]', 'Varchar(100)') DovizKodu, 
    a.b.value('MI:dovizAlis[1]', 'Varchar(100)') DovizAlis, 
    a.b.value('MI:dovizSatis[1]', 'Varchar(100)') DovizSatis 
FROM @DOVIZ_KUR d
    CROSS APPLY dovizKurList.nodes('/MI:ArrayOfDOVIZ_RETURN/MI:DOVIZ_RETURN') AS a(b)

SQL Fiddle Demo

