メソッドで使用される xmlwriter オブジェクトがあります。これをファイルにダンプして読みたいと思います。これを行う簡単な方法はありますか?
ありがとう
このコードを使用
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");
// Add a price element.
XmlElement newElem = doc.CreateElement("price");
newElem.InnerText = "10.95";
doc.DocumentElement.AppendChild(newElem);
// Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter(@"C:\data.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
MSDN にあるとおり: http://msdn.microsoft.com/en-us/library/z2w98a50.aspx
1 つの可能性は、テキスト ファイルに出力するように XmlWriter を設定することです。
using (var writer = XmlWriter.Create("dump.xml"))
{
...
}