开发者

Investigating XMLWriter object

开发者 https://www.devze.com 2023-03-09 14:41 出处:网络
How can I see the XML contents of fully populated XmlWriter object while debugging. My silverlight application doesn\'t permit to actually write to a file and che开发者_如何学Gock the contents.Have it

How can I see the XML contents of fully populated XmlWriter object while debugging. My silverlight application doesn't permit to actually write to a file and che开发者_如何学Gock the contents.


Have it write to a MemoryStream or StringBuilder instead of a file. That will allow you to check the output.


You can create the XmlWriter based on a MemoryStream, then unencode the bytes from the memory stream and display it in a text box, for example.

MemoryStream ms = new MemoryStream();
XmlWriterSettings ws = new XmlWriterSettings();
ws.Encoding = Encoding.UTF8;
XmlWriter w = XmlWriter.Create(ms, ws);
// populate the writer
w.Flush();
textBox1.Text = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Position);


An XmlReader is not "populated". It represents the state of an XML parsing operation, as that operation is in progress. This state will change as the XML is read.

0

精彩评论

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