gpt4 book ai didi

xml - XQuery [节点 ()] : The name "s" does not denote a namespace

转载 作者:行者123 更新时间:2023-12-05 05:27:20 29 4
gpt4 key购买 nike

我有一个需要分解的 xml。但我收到此错误 XQuery [nodes()]: The name "s"does not denote a namespace.

我有以下格式的 xml

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">urn:somename-com:Access.2012.Services.Patient.GetCensus</a:Action>
</s:Header>
<s:Body>
<GetCensusByUnitResponse xmlns="urn:somename-com:Access.2012.Services.Patient">
<GetCensusByUnitResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<BeddedPatients>
<BeddedPatient>
...
...
...
</GetCensusByUnitResult>
</GetCensusByUnitResponse>
</s:Body>
</s:Envelope>

;with xmlnamespaces('urn:Epic-com:Access.2012.Services.Patient' as ep,
'http://www.w3.org/2003/05/soap-envelope' as s,
'http://www.w3.org/2005/08/addressing' as a,
'http://www.w3.org/2001/XMLSchema-instance' as i)

但是当尝试使用 xquery 粉碎它时,它给了我错误。

为了切碎我写了以下查询:

select  x.n.value('(ep:AccommodationCode)[1]', 'varchar(128)') as accomdationCode
from @xml.nodes('/s:Envelope/s:Body/ep:GetCensusByUnitReeponse/ep:GetCensusByUnitResult/ep:BeddedPatients/ep:BeddedPatient') x(n)

有人可以告诉我可能是什么问题吗?提前致谢。

最佳答案

似乎 Ankur 在他/她的问题正文中添加了正确答案。 T-sql 需要命名空间声明之前 选择语句:

WITH XMLNAMESPACES ( <XML namespace declaration item>  [ { , <XML namespace declaration item> }...] )

它仍在使用 MS SQL 2016。

关于xml - XQuery [节点 ()] : The name "s" does not denote a namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19854819/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com