Tuesday, December 05, 2006

A use for Internet Explorer (XML viewer)

Normally I have little use for Internet Explorer, except at annoying sites that only work with IE. I switched to Firefox years ago and have never regretted it. Hello tabs!

However a smart guy at work showed me a handy thing that IE is actually useful for. IE does a pretty good job of rendering raw XML. It shows it in a nicely formatted, color coded way where you can open and close the branches to narrow focus to a specific area.

This is useful for me because I deal with SOAP a lot at work on the server side. Clients visiting the internal web service tend to be shaky and get themselves into a bad state, and do strange things that cause problems. We necessarily log all of the SOAP/XML that we send and receive. When a problem occurs it is very useful to see the exact SOAP content that was sent or received on the wire.

Now viewing SOAP content can be a pain. On our side we use Tomcat and Xerces. While this is robust and reliable, it also generates the XML all on one line. This is fine for a computer to process but hard for a human to read. Previously I had to copy and paste from the log file into a text editor and insert line breaks manually to see the actual valid XML/SOAP we sent that the client was having problems with.

Using IE, there's a much faster, easier and better way.

Create a document on your desktop called t.xml.
Make sure your settings have IE as the default application for .xml files.
Right click on t.xml and open using a text editor.
Replace the existing t.xml content with the XML copied from the log file.
Save t.xml and close.

Then just double click t.xml on your desktop and it comes up nicely formatted in IE with all the attributes and namespaces and everything right there. This is very handy and a real time saver.

No comments: