Reputation: 45
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 check the contents.
Upvotes: 2
Views: 924
Reputation: 161801
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.
Upvotes: 0
Reputation: 87298
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);
Upvotes: 0
Reputation: 158349
Have it write to a MemoryStream
or StringBuilder
instead of a file. That will allow you to check the output.
Upvotes: 3