XML to CSV Using XSLT

后端 未结 4 862
花落未央
花落未央 2020-11-22 08:06

I have the following XML document:


  
   Shockwave 
   Ruby 
   <         


        
4条回答
  •  面向向阳花
    2020-11-22 08:32

    This CsvEscape function is XSLT 1.0 and escapes column values ,, ", and newlines like RFC 4180 or Excel. It makes use of the fact that you can recursively call XSLT templates:

    • The template EscapeQuotes replaces all double quotes with 2 double quotes, recursively from the start of the string.
    • The template CsvEscape checks if the text contains a comma or double quote, and if so surrounds the whole string with a pair of double quotes and calls EscapeQuotes for the string.

    Example usage: xsltproc xmltocsv.xslt file.xml > file.csv

    
    
      
    
      
        
        
          
        
        ""
        
          
        
          
          
        
          
        
      
    
      
        
        
        
          "
          
        
          
          "
        
        
          "
          
        
          
          "
        
        
          "
          
        
          
          "
        
        
          
        
        
      
    
      
        project,name,language,owner,state,startDate
        
    
        
          
          ,
          
          ,
          
          ,
          
          ,
          
          
    
        
      
    
    

提交回复
热议问题