2011-06-08 73 views

回答

2

不要试图避免它们 - 使用它们!

做到这一点,最简单的方法是使用WITH XMLNAMESPACES结构 - 是这样的:

;WITH XMLNAMESPACES(DEFAULT 'http://your.name.space.here/2011/June') 
(
    -- your XQuery/XPath code here - it will by default use the namespace given 
) 

您可以轻松拥有多个命名空间,太 - 你可以给他们的前缀,以及(在使用那些你XPath表达式):

;WITH XMLNAMESPACES('http://your.name.space.here/2011/June' AS ns) 
(
    -- your XQuery/XPath code here - it will by default use the namespace given 
    ....... xmlcolumn.value('(/ns:root/ns:subelement......)[1]', 'int'). ..... 
) 

的更多细节和更多的解释

MSDN docs on Adding XML Namespaces