Consider the following TSQL:
declare @xml xml
select @xml = '<test xmlns="http://this-is-the-default-namespace-uri">some data</test>'
select x.value('namespace-uri(.)', 'varchar(100)')
from @xml.nodes('.') x(x)
What I’m trying to get from the XML is the URI of the default namespace. This is the value of the xmlns attribute on the root element. The above select statement is returning an empty string. How can I get the actual value of the xmlns?
I’m not too familiar with how fn:namespace-uri() works but this seems to return what you want…