@Test public void createNodeUsingXPathExpressionTest() throws XPathExpressionException, UnsupportedEncodingException { Node result = XMLUtils.createNodeUsingXPathExpression("/parentNode/childNode[1]", testXml); assertThat(result.getTextContent(), equalTo("1")); result = XMLUtils.createNodeUsingXPathExpression("/parentNode/childNode[2]", testXml); assertThat(result.getTextContent(), equalTo("2")); }
public static Node createNodeUsingXPathExpression(String expression, String xml) throws XPathExpressionException, UnsupportedEncodingException { return (Node) XMLUtils.createXPathExpression(expression).evaluate(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), XPathConstants.NODE); }
XMLUtils { public static Node createNodeUsingXPathExpression(String expression, String xml) throws XPathExpressionException, UnsupportedEncodingException { return (Node) XMLUtils.createXPathExpression(expression).evaluate(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), XPathConstants.NODE); } }
XMLUtils { public static Node createNodeUsingXPathExpression(String expression, String xml) throws XPathExpressionException, UnsupportedEncodingException { return (Node) XMLUtils.createXPathExpression(expression).evaluate(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), XPathConstants.NODE); } private  XMLUtils(); }
XMLUtils { public static Node createNodeUsingXPathExpression(String expression, String xml) throws XPathExpressionException, UnsupportedEncodingException { return (Node) XMLUtils.createXPathExpression(expression).evaluate(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), XPathConstants.NODE); } private  XMLUtils(); static String transformXML(final InputStream xml, final InputStream xslt); static String createPrettyXML(Document document); static XPathExpression createXPathExpression(final String expression); static Boolean createBooleanUsingXPathExpression(String expression, String xml); static NodeList createNodeListUsingXPathExpression(String expression, String xml); static Node createNodeUsingXPathExpression(String expression, String xml); }
XMLUtils { public static Node createNodeUsingXPathExpression(String expression, String xml) throws XPathExpressionException, UnsupportedEncodingException { return (Node) XMLUtils.createXPathExpression(expression).evaluate(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))), XPathConstants.NODE); } private  XMLUtils(); static String transformXML(final InputStream xml, final InputStream xslt); static String createPrettyXML(Document document); static XPathExpression createXPathExpression(final String expression); static Boolean createBooleanUsingXPathExpression(String expression, String xml); static NodeList createNodeListUsingXPathExpression(String expression, String xml); static Node createNodeUsingXPathExpression(String expression, String xml);  }