XML Notepad is good but it just doesn't fit my need...
Updated @ 2008-12-06: XML Notepad 2.5 already supports getting XML data from clipboard, thank Ah Phu.
I wrote a workflow system and it stores the form context and flow context in XML format. While trouble-shooting, I often need to query context data and analyze the XML string. When I use SQL Server Management Studio or my customize debugger to fetch the context data, what I get is a XML string. But XML Notepad only accepts XML files, so I have to press ctrl-C to copy the string, open notepad, paste the XML string, save it as a file and open it from XMLNotepad, quite a long road.
I have seen another tool, XMLSpy, it can accept XML string from clipboard and parse it immediately. Yeah, that's what I need, but XMLSpy is quite expensive. In the other way, XMLSpy is too rich for me, what I really need is a XML Notepad which can import XML string from clipboard directly.
Thanks God, XML Notepad is open source. I downloaded the source code from CodePlex and added two menu items, wrote a couple of code, my dream XML Notepad is coming...
private void toolStripMenuItem13_Click(object sender, EventArgs e)
//Save the text form clipboard as file
string rawXml = Clipboard.GetText();
//Validate the XML data
XmlDocument xd = new XmlDocument();
//Remove <?xml> declaration
if (rawXml.StartsWith("<?xml version"))
rawXml, "[<][?]xml.+?[?]>", "");
rawXml = rawXml.Substring(rawXml.IndexOf("<"));
//Use LoadXml to test if the XML is valid
//Save it as a temp file
string fileName = System.IO.Path.GetTempFileName() + ".xml";
//Call internal method to open the file
catch (Exception ex)
MessageBox.Show("Invliad XML document.");
private void toolStripMenuItem14_Click(object sender, EventArgs e)
//Prepare the XmlTextWriter
MemoryStream ms = new MemoryStream();
XmlTextWriter xtw = new XmlTextWriter(ms, Encoding.UTF8);
xtw.Formatting = Formatting.Indented;
//Dump XML to the XmlTextWriter
//Send it to the clipboard