在以前公司的时候写过一点用c#通过xslt把xml转成html的代码,在此记录一下,附示例xml和xslt。 try { string sourceDoc = “resource-sample.xml”; string xsltDoc = “resource.xslt”; XPathDocument myXPathDocument = new XPathDocument(sourceDoc); XslCompiledTransform myXslTransform = new XslCompiledTransform(); MemoryStream ms = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(ms, null); myXslTransform.Load(xsltDoc); myXslTransform.Transform(myXPathDocument, null, writer); ms.Seek(0, SeekOrigin.Begin); StreamReader stream = new StreamReader(ms); this.txtOutput.Text = stream.ReadToEnd(); writer.Close(); } catch (FileNotFoundException filexc) { MessageBox.Show(“File Not Found!”,… Read More »