XMLQuery { public XMLQuery find(String query) { try { XPath xpath = getXPath(); XPathExpression expr = xpath.compile(query); XMLQuery ret = new XMLQuery(); for (Node node : this.nodes) { NodeList result = (NodeList) expr.evaluate(node, XPathConstants.NODESET); convertNodeList(result, ret.nodes); } return ret; } catch (XPathExpressionException e) { throw new RuntimeException(e); } } XMLQuery();  XMLQuery(List<Node> nodes);  XMLQuery(String xml); XMLQuery append(String xml); @Override String toString(); String toXML(); XMLQuery clone(); XMLQuery find(String query); String text(); int size(); XMLQuery item(int i); XMLQuery get(int i); String getContent(); String getContent(String parent); static XMLQuery create(List<Node> nodes); static XMLQuery parse(byte[] xml, boolean ns); void sort(Comparator<XMLQuery> comparator); static XMLQuery create(Node... list);  }
@Test public void testFind() { XMLQuery q = new XMLQuery( "<r><a><inner>1</inner><inner>2</inner></a><b v=\"v1\"/><c v=\"v2\">i</c><d><inner>3</inner></d></r>"); assertEquals( "<r><a><inner>1</inner><inner>2</inner></a><b v=\"v1\"/><c v=\"v2\">i</c><d><inner>3</inner></d></r>", q.clone().find(" assertEquals( "<r><a><inner>1</inner><inner>2</inner></a><b v=\"v1\"/><c v=\"v2\">i</c><d><inner>3</inner></d></r>", q.clone().find("./r").toXML()); assertEquals( "<r><a><inner>1</inner><inner>2</inner></a><b v=\"v1\"/><c v=\"v2\">i</c><d><inner>3</inner></d></r>", q.clone().find("r").toXML()); assertEquals( "<r><a><inner>1</inner><inner>2</inner></a><b v=\"v1\"/><c v=\"v2\">i</c><d><inner>3</inner></d></r>", q.clone().find("/r").toXML()); assertEquals("<a><inner>1</inner><inner>2</inner></a>", q.clone().find(" assertEquals("<inner>1</inner><inner>2</inner><inner>3</inner>", q.clone().find(" assertEquals("<inner>2</inner>", q.clone().find(" assertEquals("<inner>1</inner><inner>2</inner>", q.clone().find(" assertEquals("<inner>1</inner><inner>2</inner>", q.clone().find(" assertEquals("<inner>1</inner><inner>2</inner>", q.clone().find(" assertEquals("<inner>1</inner><inner>2</inner><inner>3</inner>", q.clone().find(" assertEquals("<b v=\"v1\"/><c v=\"v2\">i</c>", q.clone().find("/@v").toString()); assertEquals("", q.clone().find(" assertEquals("<b v=\"v1\"/>", q.clone().find(" assertEquals("[v=\"v1\"]", q.clone().find(" assertEquals("[v=\"v1\"]", q.clone().find(" }