Sorting of XML file by XMLElement's InnerText

后端 未结 4 797
野性不改
野性不改 2020-12-21 12:41

Please have a look at the XML file. I would like to sort the XML file by tag


  
    ABC&         


        
4条回答
  •  悲&欢浪女
    2020-12-21 13:29

    use XSLT

    E.g:

    dataSort.xslt:

     
    
    
    
        
            
        
    
    
    
        
            
                
        
    
    
    

    Sample.cs:

    //convert data.xml to sortedData.xml
    
    using System;
    using System.Xml.Xsl;
    
    class Sample {
        static public void Main(){
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load("dataSort.xslt");
            xslt.Transform("data.xml", "sortedData.xml");
        }
    }
    

提交回复
热议问题