XslCompiledTransform xsl = new XslCompiledTransform();
            if (!File.Exists(@"F:\XML&XSLT\demo\xml\index_html5.xsl"))
            {
              
            }
            try
            {
                xsl.Load(new System.Xml.XPath.XPathDocument(@"F:\XML&XSLT\demo\xml\index_html5.xsl"));
            }
            catch
            { }
            xsl.Transform(@"F:\XML&XSLT\demo\xml\index_html5.xml", @"F:\XML&XSLT\demo\xml\index.html");
            //System.Diagnostics.Process.Start(@"F:\XML&XSLT\demo\xml\index.html");

 

起初我使用 xsl.Load(@"F:\XML&XSLT\demo\xml\index_html5.xsl");出现异常:

因为安全原因,此 XML 文档中禁用 DTD。要启用 DTD 处理,将 XmlReaderSettings 上的 ProhibitDtd 属性设置为 false,并将该设置传递给 XmlReader.Create 方法。

后来使用xsl.Load(new System.Xml.XPath.XPathDocument(@"F:\XML&XSLT\demo\xml\index_html5.xsl"));这样可以正常执行。

相关文章:

  • 2021-10-12
  • 2021-07-21
  • 2021-07-03
  • 2021-08-09
  • 2021-06-04
  • 2022-01-19
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-09-28
  • 2021-12-05
相关资源
相似解决方案