-1

使用 Visual Studio 2010 和 C# 进行 XSLT 转换。我需要帮助。根据我如何进行转换,我得到不同的输出。在 VS 调试器中运行转换,我得到以下输出。注意非转义标签。

<Service_Log>
<row>
      <EntryNumber>00</EntryNumber>
      <ErrorID>B004</ErrorID>
      <ErrorDate>2/06/2007 18:06:07</ErrorDate>
      <ErrorInfo>00000000</ErrorInfo>
      </row>
<row>
...
</Service_Log>

当我使用以下代码片段在 C# 中运行转换时,我得到的输出带有转义的 xml 标签 - 我不希望它们转义。我错过了什么?

XslCompiledTransform trans = new XslCompiledTransform();
XmlWriterSettings settings = new XmlWriterSettings();
string fname = FixPath(WorkingFolder) + "Phase1.xml";
XmlWriter writer = XmlWriter.Create(fname, settings);
trans.Transform(xmlFile, writer);


&lt;readsym_Service_Log&gt;
&lt;row&gt;
      &lt;EntryNumber&gt;00&lt;/EntryNumber&gt;
      &lt;ErrorID&gt;B004&lt;/ErrorID&gt;
      &lt;ErrorDate&gt;2/06/2007 18:06:07&lt;/ErrorDate&gt;
      &lt;ErrorInfo&gt;00000000&lt;/ErrorInfo&gt;

      &lt;/row&gt;
&lt;row&gt;
...
4

1 回答 1

0

尝试这样的事情:

        string inputFileName = @"XMLFile1.xml";
        string xsltFileName = @"XSLTFile1.xslt";
        string outputFileName = @"XMLFile2.xml";


        XslCompiledTransform trans = new XslCompiledTransform();
        XsltSettings settings = new XsltSettings();
        settings.EnableScript = true;
        trans.Load(xsltFileName, settings, null);

        XmlWriter writer = XmlWriter.Create(outputFileName);

        trans.Transform(inputFileName, writer);
于 2012-06-15T03:00:06.240 回答