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