The Xalan package has a handy example program, ApplyXPath.java, that enables you to apply an XPath expression to a document and see what the results would be, which is great for testing. To run this example, you need to compile ApplyXPath.java into ApplyXPath.class using the java.exe tool that comes with Java.
As an example, Ill apply the XPath expression PLANET/ NAME to planets.xml using ApplyXPath.class. Heres the result, displaying all <NAME> elements that are children of <PLANET> elements (the <output> tags are added by ApplyXPath):
%java ApplyXPath planets.xml PLANET/NAME <output> <NAME>Mercury</NAME><NAME>Venus</NAME><NAME>Earth</NAME> </output>