Retrieving XML element name using t-SQL

前端 未结 2 465
梦毁少年i
梦毁少年i 2021-02-07 04:39

If I have:


  
    john
    something or other
  
  

        
相关标签:
2条回答
  • 2021-02-07 05:22

    Actually, sorry, the best I've got is:

    select distinct r.value('fn:local-name(.)', 'nvarchar(50)') as t
    FROM
        @xml.nodes('//quotes/*/*') AS records(r)
    

    Guess I answered my own question...

    0 讨论(0)
  • 2021-02-07 05:37
    DECLARE @xml as xml
    SET @xml = '<Address><Home>LINE1</Home></Address>'
    
    SELECT Nodes.Name.query('local-name(.)') FROM @xml.nodes('//*') As Nodes(Name)
    

    This will give the list of all elements

    0 讨论(0)
提交回复
热议问题