您好我在数据库表列中有以下xml结构:
DECLARE @Response XML =
'<star:ShowInfo xmlns="http://www.starstandard.org/STAR/5"
xmlns:ns2="http://www.openapplications.org/oagis/9"
xmlns:star="http://www.starstandard.org/STAR/5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" releaseID="5.1.5"
xsi:noNamespaceSchemaLocation="">
<ShowDataArea>
<ServiceInfo>
<SVPlanInfo>
<AKStatus>
<Code>Error</Code>
<STText xsi:type="ns2:TextType">E12143 - Please fetch me from this xml </STText>
</AKStatus>
</SVPlanInfo>
</ServiceInfo>
</ShowDataArea></star:ShowInfo>'
在上面的xml中,我需要获取 STText 值 E12143 - 请从此xml 中获取。谁能指出我怎么做呢?
我尝试了以下但它似乎无法工作:
;WITH XMLNAMESPACES ('http://www.w3.org/2001/XMLSchema' as xsd,
'http://www.w3.org/2001/XMLSchema-instance' as xsi)
SELECT @Response.value('(/xsd:Response)[1]','nvarchar(500)') as ExceptionMessage
答案 0 :(得分:0)
多么痛苦。
删除:
xmlns="http://www.starstandard.org/STAR/5"
这不是一个sql问题,而是一个名称空间混乱的问题。
有时,通过测试像
这样的地方,它可以解决这个问题