XML文件转化为和HTML文件
时间:2011-05-05 来源:xuebingz
/// < summary>
///将xml转化为html
/// < /summary>
/// < param name="XmlPath">xml文件路径< /param>
/// < param name="XslFilePath">xslt文件路径< /param>
/// < param name="htmlFilePath">声称的html文件路径< /param>
public static void XmlTransToHtml(string xmlPath, string xslFilePath, string htmlFilePath)
{
//生成Html文件路径
string HtmlFilePath = htmlFilePath;
XPathDocument myXPathDoc = new XPathDocument(xmlPath);
XslCompiledTransform myXslTrans = new XslCompiledTransform();
//加载XSL文件
myXslTrans.Load(xslFilePath);
XmlTextWriter myWriter = new XmlTextWriter(HtmlFilePath, System.Text.Encoding.Default);
myXslTrans.Transform(myXPathDoc, null, myWriter);
myWriter.Close();
}
在测试的类中调用这个方法,结果s就是HTML格式.