XSLT - How to keep only wanted elements from XML

前端 未结 2 718
青春惊慌失措
青春惊慌失措 2020-12-03 00:28

I have a number of XML files containing lots of overhead. I wish to keep only about 20 specific elements and filter out anything else. I know all the names of the elements I

2条回答
  •  臣服心动
    2020-12-03 00:47

    In XSLT you usually don't remove the elements you want to drop, but you copy the elements you want to keep:

    
    
    
        
    
         
            
                
            
         
    
         
            
                
                                   
            
         
    
         
            
         
    
         
            
         
    
    
    

    The example above copies only currency and currency_code3. The output is as follows:

    
    
       
          somecurrency
          
       
    
    

    Note: I added a namespace declaration for your prefix ns.

    If you want to copy everything except a few elements, you may see this answer

提交回复
热议问题