xml转换成html文件方法

作者:袖梨 2022-06-25

xml转换成html文件方法

/// < 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();
        }

 

相关文章

精彩推荐