/** * Returns the NodeList corresponding to the XPath query. * * @param xmlNode * The node where the search should be performed. * @param xPathString * XPath query string * @return the NodeList corresponding to the XPath query */ public static NodeList getNodeList(final Node xmlNode, final String xPathString) { try { final XPathExpression expr = createXPathExpression(xPathString); return (NodeList) expr.evaluate(xmlNode, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new DSSException(e); } }
/** * Returns the String value of the corresponding to the XPath query. * * @param xmlNode * The node where the search should be performed. * @param xPathString * XPath query string * @return string value of the XPath query */ public static String getValue(final Node xmlNode, final String xPathString) { try { final XPathExpression xPathExpression = createXPathExpression(xPathString); final String string = (String) xPathExpression.evaluate(xmlNode, XPathConstants.STRING); return string.trim(); } catch (XPathExpressionException e) { throw new DSSException(e); } }