Sample code for converting xml to html using XSLT

Source: Internet
Author: User
Tags xsl xslt
C # use XSLT to convert an xml document to an html document. use xslt to convert an xml document to html. The following c # function: reference the following namespace:
C # use XSLT to convert an xml document to an html document. use xslt to convert an xml document to html. The following c # function: reference the following namespace: using System. xml; using System. xml. xsl; method implementation: public static string ConvertXML (XmlDocument InputXMLDocument, string using tfilepath, using targumentlist using targs) {System. IO. stringWriter sw = new System. IO. stringWriter (); extends compiledtransform extends trans = new extends compiledtransform (); extends trans. load (effectfilepath); implements trans. transform (InputXMLDocument. createNavigator (), repeated targs, sw); return sw. toString ();} the example xml file is as follows:
 
   
      
       
       
     
    
      
       
     
  
 The sample xslt file is as follows:
 
 
    
      
   

  • The called c # code: XmlDocument xDoc = new XmlDocument (); xDoc. load (@ "C: \ sample. xml "); string returnhtml = ConvertXML (xDoc, @" C: \ sample. xslt ", new extension targumentlist (); enter the following html:

    Bollywood

    • Antra mali
    • Deepika Padukone
    • Mandira Bedi
    Hollywood
    • Jennifer Lopez
    • Jessica Alba

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.