带名称空间的openxml

时间:2016-03-03 07:29:30

标签: sql sql-server xml sqlxml

有人可以帮助提取这个:

<Customize xmlns="http://utsavfashion.com/web/schemas">   
    <customize_details> 
        <entityid>876</entityid>    
    </customize_details>
</Customize>

我正在使用:

DECLARE @xml_hndl INT
EXEC sp_xml_preparedocument @xml_hndl OUTPUT, @str

SELECT *
FROM OPENXML(@xml_hndl, '/Customize/customize_details', 2)
WITH (entityid INT)

EXEC sp_xml_removedocument @xml_hndl

除非我从xml

中删除命名空间,否则我什么也得不到

1 个答案:

答案 0 :(得分:4)

的XQuery:

.gradle

的OpenXML:

DECLARE @x XML = '
<Customize xmlns="http://utsavfashion.com/web/schemas">   
    <customize_details> 
        <entityid>876</entityid>    
    </customize_details>
</Customize>'

SELECT t.c.value('.', 'INT')
FROM @x.nodes('*:Customize/*:customize_details/*:entityid') t(c)