我正在轉換一個XML文檔,但在轉換後,我的DTD消失了,並且第一行告訴XML版本丟失。XML轉換後保留DTD
<?xml version="1.0"?>
我使用轉換XML文件中的代碼是:
// Load the style sheet.
var xslt = new XslCompiledTransform();
xslt.Load("XSLTFile1.xslt");
// Create the writer.
var settings = new XmlWriterSettings
{
Indent = true,
IndentChars = "\t",
ConformanceLevel = ConformanceLevel.Auto,
Encoding = Encoding.UTF8,
};
var mydoc = XDocument.Load("Doc1.xml");
var writer = XmlWriter.Create("Doc2.xml", settings);
// Execute the transform and output the results to a file.
if (writer != null)
{
xslt.Transform(mydoc.CreateReader(), writer);
writer.Close();
}
任何想法?