private NodeList getNodeList(Element base, String xpathExpression) throws TransformerException, IOException, SAXException, XPathExpressionException, ParserConfigurationException {
validate();
String baseString = XMLFormatter.prettyPrint(base);
LOG.createAppender()
.appendBold("Node XML String:")
.appendXML(baseString)
.log();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(baseString)));
NodeList nodeList = (NodeList) xPath.evaluate(xpathExpression, document, XPathConstants.NODESET);
if (nodeList == null) {
throw new IllegalArgumentException(String.format("Xpath Expression '%s' not found.", xpathExpression));
}
LOG.createAppender()
.appendBold("Get Node List:")
.appendProperty("Xpath Expression", xpathExpression)
.appendProperty("Number of Elements Found", nodeList.getLength())
.log();
return nodeList;
}