Hi Folks,i have the following XML-Structure <user> <user_name>user1</user_name> <tables> <table>table1</table> </tables> <tables> <table>table1_1</table> </tables> </user> <user> <user_name>user2</user_name> <tables> <table>table2</table> </tables> </user>
and i want to get the output:user1--> table1--> table1_1user2--> table2but i get:user1--> table1--> table1_1--> table2instead.I use the following routine with nested loops:declare user_name_ CURSOR FORselect Attributes.Attribute.value('.','varchar(max)') as AttributeValue from @xml_user_struct.nodes('/root/user/user_name') Attributes (Attribute);declare table_ CURSOR FORselect Attributes.Attribute.value('.','varchar(max)') as AttributeValue from @xml_user_struct.nodes('/root/user/tables/table') Attributes (Attribute);declare @user_string varchar(100);declare @table_string varchar(100);OPEN user_name_OPEN table_FETCH NEXT FROM user_name_ INTO @user_string-- LOOP 1WHILE @@FETCH_STATUS = 0BEGIN PRINT @user_string FETCH NEXT FROM user_name_ INTO @user_string FETCH NEXT FROM table_ INTO @table_string -- LOOP 2 WHILE @@FETCH_STATUS = 0 begin PRINT '--> ' + @table_string FETCH NEXT FROM table_ INTO @table_string end close table_; deallocate table_;ENDclose user_name_;deallocate user_name_;What should i correct on my routine?Thanks for your help.