开发者

Writing a System.Xml.XmlElement to a file on disk

I'm having trouble with writing a System.Xml.XmlElement to disk using C# .NET.

This is what I'm trying to do at the moment and failing:

XmlWriterSettings oS开发者_如何学编程ettings = new XmlWriterSettings();
oSettings.Indent = true;
oSettings.OmitXmlDeclaration = false;
oSettings.Encoding = Encoding.ASCII;

XmlWriter writer = XmlWriter.Create(@"C:\xmlfile.xml", oSettings);
System.Xml.XmlElement xml = sc.WFCFunctionCall();
xml.WriteContentTo(writer2);

the variable 'xml' definitely contains valid XML, I've stopped in the debugger and inspected.

xml.WriteTo(writer2)

also does not work.

Is there a simple way of doing this?

Cheers! Nick.


"Does not work" doesnt give us much to go on, but if I were to guess im thinking that you're inspecting the file right after the call to xml.WriteTo(...) and there is nothing there. You might try calling Close and/or Dispose on the XmlWriter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜