if ( args.length != 2 ) {
System.out.println( "usage: PrintXPath expression file.xml" );
System.exit(1);
}
String expression = args[0], filename = args[1];
XPath xpath = XPathFactory.newInstance().newXPath();
InputSource inputSource = new InputSource( filename );
NodeList elements = (NodeList)xpath.evaluate(
expression, inputSource, XPathConstants.NODESET );
for( int i=0; i<elements.getLength(); i++ )
if ( elements.item(i) instanceof Element ) {
printXML( (Element)elements.item(i) );
} else
System.out.println( elements.item(i) );