首页 > 代码库 > 随笔- Get Root Element and namespace of xml in mssql

随笔- Get Root Element and namespace of xml in mssql

declare @x xml
set @x =
‘<Chicago xmlns="http://workshop">
<Area>A1</Area>
<Group>5</Group>
<Question>Q1</Question>
</Chicago>‘

declare @r nvarchar(50)
set @r = @x.value(‘local-name(*[1])‘, ‘nvarchar(50)‘)
--SELECT @x.query(‘local-name(/*[1])‘)

select @r

select @x.value(‘namespace-uri(*[1])‘, ‘nvarchar(100)‘)

随笔- Get Root Element and namespace of xml in mssql