For this xml (in a SQL 2005 XML column):
1
DECLARE @xml as xml
DECLARE @path as varchar(max)
DECLARE @index int, @count int
SET @xml =
'
1
'
SELECT @index = 1
SET @count = @xml.query('count(/doc/b/@*)').value('.','int')
WHILE @index <= @count
BEGIN
SELECT @xml.value('local-name((/doc/b/@*[sql:variable("@index")])[1])', 'varchar(max)')
SET @index = @index + 1
END
for element 'b'
it returns
You can build a loop to get attributes for each element in the xml.
BTW The XML in your sample should be closed at closing doc tag.