Given an user input string, how can I tell whether it is a
valid Xpath expression or not in Java. Just curious, since I cannot
find a way to do it using javax.xml.xpath li
Run the XPath against some example XML document (e.g. ). In most cases it won't return anything, but what you care about is whether it will throw an exception.