Here's a tool whose main job is to remove some pain from your life: XPathMania.  It's like Percocet, but you won't get an addiction.  If you use it so much that you are in danger of forming an addiciton, you'll notice that it's not the best tool for this job.  BUT, if you're a casual XPather, like me, you'll LOVE it :)  

Why is it so great?  Well, here is the way I developed using XPath before XPathMania:

  • 1. Edit your XPath Query (probably a string variable)
  • 2. Run your code.
  • 3. See that it didn't select the nodes you wanted it to.
  • 4. Try to keep a good attitude.
  • 5. Repeat.

I'm sure I'm not the only one that hates doing things that way.

XPathMania is a free addin for Visual Studio that allows you to enter sample XPath queries and see which nodes would be selected by that XPath query. 

So, once you install XPathMania, open up an XML document, like the one sampled below:

Now, click the View / Other Windows Menu, and select XPathMania, like so:

And you'll be greeted with the XPathMania window.  It's a modal window so you can't edit the XML while it's open, but you can drag it around if you need to:

Then, start typing in your XPath queries, and seeing what it selects for you: