### Question:
XmlUtil { public static Object xpath(String xml, String xpath) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); XPathFactory xPathfactory = XPathFactory.newInstance(); XPathExpression expr = xPathfactory.newXPath().compile(xpath); return expr.evaluate(doc); } catch (ParserConfigurationException e) { throw Exceptions.propagate(e); } catch (SAXException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(e); } catch (XPathExpressionException e) { throw Exceptions.propagate(e); } }  static Object xpath(String xml, String xpath);  }### Answer:
@Test public void testXpath() throws Exception { String xml = "<a><b>myb</b></a>"; assertEquals(XmlUtil.xpath(xml, "/a/b[text()]"), "myb"); }