dfactory.setNamespaceAware(true);
  public void doMain(String[] args)    throws Exception  {    filename = args[0];    xpath = args[1];    if ((filename != null) && (filename.length() > 0)        && (xpath != null) && (xpath.length() > 0))    {      // Tell that we're loading classes and parsing, so the time it       // takes to do this doesn't get confused with the time to do       // the actual query and serialization.      System.out.println("Loading classes, parsing "+filename+", and setting up serializer");            // Set up a DOM tree to query.      InputSource in = new InputSource(new FileInputStream(filename));      DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();      Document doc = dfactory.newDocumentBuilder().parse(in);            // Set up an identity transformer to use as serializer.      Transformer serializer = TransformerFactory.newInstance().newTransformer();      serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");      // Use the simple XPath API to select a nodeIterator.      System.out.println("Querying DOM using "+xpath);      NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);      // Serialize the found nodes to System.out.      System.out.println("<output>");                        Node n;      while ((n = nl.nextNode())!= null)      {                 serializer.transform(new DOMSource(n), new StreamResult(System.out));        System.out.println();      }      System.out.println("</output>");    }    else    {      System.out.println("Bad input args: " + filename + ", " + xpath);    }  }