<p>How can I verify a given xpath string is valid in C#/.NET?</p>

<p>I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against?</p>

How can I verify a given XPath string is valid in C#/.NET?
You try to build an
```
XPathExpression
```
from it and catch the exception.
```
```
try 
{
    XPathExpression.Compile(xPathString);
}
catch (XPathException ex)
{
    MessageBox.Show("XPath syntax error: " + ex.Message);
}
```
```