Saturday, October 24, 2009

Outputting XML to a file

A quick way to debug XML contents (I'm using this as  apart of a webservice call - where the response is long)

//Create an XML document
XmlDocument doc = new XmlDocument();

//Do stuff with it (add elements, properties, nodes, update text whatever)
....


// Save the document to file so you can look at it later
doc.Save("C:\\temp.xml"); 

// You could also do it as - particularly if you have a long path to where you are saving your files

doc.Save(@"C:\temp.xml");



 
//Otherwise, dump into the output window
doc.Save(Console.Out);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.