XPathValidator.dev – Quickly and easily validate and test your XPath expressions.

If you’ve never heard of XPath you can think of it as a quick and easy way to query an XML document, it uses a path notation for navigating through the hierarchical structure of XML similar to that of a URL. I use XPath’s on a daily basis and use it to return elements from UI visual trees (you can find more about this from the presentation I did for Digital Lincoln) but I’ve often found it hard to test expressions as they are being written and thought a xpath validator would be really useful. To address this I started by writing a basic console application which would take an XPath as an input and check if it was valid – this worked well but I thought a website would be easier so I built XPathValidator.dev. I am aware there are a few other XPath testing sites out there but I wanted something simple and clean that would just get the job done.

There are two ways the site can be used for; the first is to just validate XPath expressions and the second is to run those expressions and return the result by also providing XML. Let’s quickly try out both these features.

XPath Validation

This is the main feature I built the site for but I image most people will be more interested in evaluating their XPath expressions however I’ll quickly go through it. Simply provide an expression and hit validate. If you’re XPath if syntaxly correct you will get a nice green tick.


And if not you’ll get a cross with a error message.


Expression Evaluation

This is what I image most people will use the site for so let’s see what it can do! Let’s start basic and return a node. I’m going to using the XML Example Document provided by W3Schools.


Great! How about selecting all the book prices?


Or even get the title nodes where their price > 35.


There are a lot more XPath operators and functions out there and I suggest you check out the documentation over on W3Schools if you’re interested in learning more. The site was built in .Net Core 3.1 and is open source on GitHub, I’m happy to accept pull requests with additional functionality and if you have any problems then just open an issue. Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.