@Test public void testParseXmlThrowsException() throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { thrownException.expectMessage(RESPONSE_IS_NOT_WELL_FORMED); XMLUtils.parseXml("<note>\n" + "<to>Tove</to>\n" + "<from>Jani</from>", HEADER_XPATH); }
public static String parseXml(String xml, String expression) throws ParserConfigurationException, IOException, XPathExpressionException, SAXException { DocumentBuilder builder = ResourceLoader.getDocumentBuilder(); Document document; try { document = builder.parse(new InputSource(new StringReader(xml))); } catch (SAXException e) { throw new RuntimeException(RESPONSE_IS_NOT_WELL_FORMED + xml, e); } XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(document); }
XMLUtils { public static String parseXml(String xml, String expression) throws ParserConfigurationException, IOException, XPathExpressionException, SAXException { DocumentBuilder builder = ResourceLoader.getDocumentBuilder(); Document document; try { document = builder.parse(new InputSource(new StringReader(xml))); } catch (SAXException e) { throw new RuntimeException(RESPONSE_IS_NOT_WELL_FORMED + xml, e); } XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(document); } }
XMLUtils { public static String parseXml(String xml, String expression) throws ParserConfigurationException, IOException, XPathExpressionException, SAXException { DocumentBuilder builder = ResourceLoader.getDocumentBuilder(); Document document; try { document = builder.parse(new InputSource(new StringReader(xml))); } catch (SAXException e) { throw new RuntimeException(RESPONSE_IS_NOT_WELL_FORMED + xml, e); } XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(document); } private  XMLUtils(); }
XMLUtils { public static String parseXml(String xml, String expression) throws ParserConfigurationException, IOException, XPathExpressionException, SAXException { DocumentBuilder builder = ResourceLoader.getDocumentBuilder(); Document document; try { document = builder.parse(new InputSource(new StringReader(xml))); } catch (SAXException e) { throw new RuntimeException(RESPONSE_IS_NOT_WELL_FORMED + xml, e); } XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(document); } private  XMLUtils(); static String parseXml(String xml, String expression); }
XMLUtils { public static String parseXml(String xml, String expression) throws ParserConfigurationException, IOException, XPathExpressionException, SAXException { DocumentBuilder builder = ResourceLoader.getDocumentBuilder(); Document document; try { document = builder.parse(new InputSource(new StringReader(xml))); } catch (SAXException e) { throw new RuntimeException(RESPONSE_IS_NOT_WELL_FORMED + xml, e); } XPath xPath = XPathFactory.newInstance().newXPath(); return xPath.compile(expression).evaluate(document); } private  XMLUtils(); static String parseXml(String xml, String expression);  }