XPathHelper { public NodeList getNodeList(String pathExpr, Node node) { try { return (NodeList) xPath.evaluate(pathExpr, node, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new IllegalArgumentException("XPath '" + pathExpr + "' invalid.", e); } } XPathHelper(XPath xPath); String getString(String pathExpr, Node node); NodeList getNodeList(String pathExpr, Node node); Node getNode(String pathExpr, Node node);  }
@Test public void testGetNodeList() throws Exception { NodeList nodeList = xPathHelper.getNodeList("/xml/firstTag/innerTag/valueTag[.='A']", xmlDoc); assertEquals(2, nodeList.getLength()); Node valueTagOne = nodeList.item(0); assertEquals("valueTag", valueTagOne.getNodeName()); assertEquals("A", valueTagOne.getTextContent()); Node valueTagTwo = nodeList.item(1); assertEquals("valueTag", valueTagTwo.getNodeName()); assertEquals("A", valueTagTwo.getTextContent()); }