使用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);
<readsym_Service_Log>
<row>
<EntryNumber>00</EntryNumber>
<ErrorID>B004</ErrorID>
<ErrorDate>2/06/2007 18:06:07</ErrorDate>
<ErrorInfo>00000000</ErrorInfo>
</row>
<row>
...
答案 0 :(得分: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);