I've been working on XML and Xpath for several years now. However, I tend to get a little rusty with the Xpath syntax every now and then or just need a simple tool to test a complex query. After looking for a while, I didn't see much out there that was worth while, so I decided to write one of my own about a year ago. Hopefully everyone here will find it as useful as I have.
The XPath Analyzer is a simple utility tool that will allow you to evaluate queries against an XML instance. It's written as an HTA application. For those who aren't familiar with HTAs, it's basically an HTML file with different security permissions and a few extensions. Right now you're probably saying to yourself, "Special Security Permissions! Screw that!", let me reassure you that I'm not doing anything malicious or making any attempt to violate your privacy. But if you don't believe me, the code is not encrypted, so take a look for yourself before running the application.
How to use
To launch the application, unzip the files and double click on XPathAnalyzer.hta. Next, load a well formed XML document from your file system by clicking the "Load" button. By default, Xpath Analyzer is set to use MSXML 4.0. If you don't have MSXML 4.0, XPath Analyzer will prompt you to install it. However, if you choose not to install, you can select MSXML 3.0 which is installed by IE 6.0. This will load the XML instance into memory and display the XML in the top pane. Xpath Analyzer will also detect all your namespace bindings from the instance and load them to the namespace bindings drop down.
You can also edit the XML document that's loaded in the top pane. It's an extremely crude XML editor. In fact, it's just a
div tag that has the
contentEditable attribute turned on. Once you're satisfied with your changes, you must click "Reload" to accept those changes.
Now that your document is loaded, you can begin writing your Xpath queries in the text box. Click "Evaluate" to test your query. The results are then displayed in the lower panel.
Points of Interest
- Included in this application is a tabstrip behavior that you can reuse.
- I wanted the XML documents to be color coded in the two panels, so I had to dynamically transform the XML to HTML. In doing research for this feature, I ran into an article posted on Developmentor's website that pointed to the default XSL file that IE uses to display XML. Unfortunately it was written for MSXML2, so I translated the file to XSLT.
- The application also has a link to MSDN's XPath documentation, in the right tab of the tabstrip.