Verify an XPath in .NET

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

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?


You try it out and catch the exception.

An empty document will be enough.

XmlDocument doc = new XmlDocument();
XPathNavigator nav = doc.CreateNavigator();
  XPathExpression expr = nav.Compile(xPathString);
catch (XPathException)
  MessageBox.Show("Your XPath is invalid");

Need Your Help

How and where to handle exceptions in a 3-tier web application? Specifically Sql Database Exceptions sql-server design exception-handling 3-tier

I'm building the standard 3-tier ASP.NET web application but I'm struggling as to where to do certain things - specifically handling exceptions.

Get iOS client to respond to SignalR request when app is backgrounded

ios iphone xamarin signalr background-process

I'm quite new to xamarin iOS programming, so this might be a dumb question..