Get tag name/attribute name in XML using XSLT

后端 未结 3 1452
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 02:20

What\'s the way to get a tag name and attribute name in XML?

If I have a XML file like this:





        
3条回答
  •  天涯浪人
    2021-01-05 02:52

    Output the name of an element or attribute using one of name() or local-name():

    
    
    

    Assume this document:

    
        
        
        
        
    
    

    Then this stylesheet:

    
        
        
            
                
                
            
        
        
            
        
    
    

    Produces:

    
       apple
       banana
       sugar
       cat
       color
       color
       taste
       size
    
    

    Notice that both elements and attributes are handled by the same template.

提交回复
热议问题