XPath xpath = XPathFactory.newInstance().newXPath();
String expression = args[1];
InputSource inputSource = new InputSource(args[0]);
+ long startTime = System.nanoTime();
NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
+ long evalTime = (System.nanoTime() - startTime) / 1000000;
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
StreamResult o = new StreamResult(System.out);
- System.out.println("<xml_result>");
+ startTime = System.nanoTime();
+ System.out.println("<xml_result num=\"1\">");
for(int i = 0; i < nodes.getLength(); i++){
Node n = nodes.item(i);
switch (n.getNodeType()) {
System.out.println();
};
System.out.println("</xml_result>");
+ long printTime = (System.nanoTime() - startTime) / 1000000;
+ System.err.println("evaluation time: " + evalTime + "ms");
+ System.err.println("serialization time: " + printTime + "ms");
} catch (XPathException e) {
System.out.println (e.getCause());
} catch (Exception e) {