1
我想在SQL Server 2008中運行一些查詢,並且沒有得到結果。我做了一些在線調查,並提出了以下查詢。我玩過,並能夠返回根節點,但我需要內部的值,並有一個呼叫節點數組,我需要它的值。節點陣列上的SQL Server 2008 xpath
WITH XMLNAMESPACES ('http://api.myapi.com/resource' as r)
select c.value('@AgentCall','varchar(max)') as value
from mytable cl
outer apply cl.callinfoxml.nodes('//Call') as q(c)
示例XML:
<r:ResourceList xmlns:r="http://api.myapi.com/resource" xmlns="http://api.myapi.com/data" totalResults="1">
<Call id="1123570170003">
<FromNumber>14062618272</FromNumber>
<ToNumber>14062618272</ToNumber>
<State>READY</State>
<BatchId>12827094003</BatchId>
<BroadcastId>14633834003</BroadcastId>
<ContactId>818582749003</ContactId>
<Inbound>false</Inbound>
<Created>2016-09-22T06:22:18Z</Created>
<Modified>2016-09-22T06:22:18Z</Modified>
<AgentCall>false</AgentCall>
</Call>
</r:ResourceList>
謝謝。這與將選擇值更改爲'c.value('(AgentCall)[1]','varchar(max)')AS值' – Silas