2009-06-28 6 views
0

다음 코드의 xmlns 특성으로 필요한 값을 얻을 수 없습니다. xmlns가 아닌 다른 속성과 잘 작동합니다. 나는 주어진 xml에 대한 제어권이 없다 - 어떻게 CrpId 값을 얻을 수 있는가?요소에 xmlns 특성이있는 경우 openxml에서 값을 가져올 수 없습니다.

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 

답변

0

나는 전혀 자신의 OpenXML을 모르겠지만, this FAQ는 답을 갖고있는 것 같아요. 기본적으로 이는 특정 네임 스페이스 (xlmns 속성으로 인해)에 요소가 있기 때문에 쿼리에 동일한 네임 스페이스를 지정할 수 있어야합니다. 특정 문제에이 변환

, 난 당신이 원하는 생각 :

declare @CrpId int, @i int, @xml xml 
set @xml = 
'<NewProgressReportResult xmlns="http://myDomain.com/crp"> 
<CrpId>2160</CrpId> 
</NewProgressReportResult>' 

set @ns = '<root xmlns:ns="http://myDomain.com/crp"/> 

exec sp_xml_preparedocument @i output, @xml, @ns 

select 
CrpId 
from openxml (@i, '[ns:NewProgressReportResult]', 2) 
with ( 
     [ns:CrpId] int 'CrpId' 
) 

exec sp_xml_removedocument @i 
관련 문제