以下代码中的 xmlns 属性使我无法获得所需的值。适用于任何其他属性,但不适用于 xmlns。我无法控制给定的 xml - 如何获取 CrpId 值?
declare @CrpId int, @i int, @xml xml
set @xml =
'<NewProgressReportResult xmlns="http://myDomain.com/crp">
<CrpId>2160</CrpId>
</NewProgressReportResult>'
exec sp_xml_preparedocument @i output, @xml
select
CrpId
from openxml (@i, 'NewProgressReportResult', 2)
with (
CrpId int 'CrpId'
)
exec sp_xml_removedocument @i