public static String valueFromXPath ( Document parsedXml , String path ) { XPath xPath = XPathFactory . newInstance ( ) . newXPath ( ) ; try { return xPath . evaluate ( path , parsedXml . getDocumentElement ( ) ) ; } catch ( XPathExpressionException exception ) { LOG . error ( "Incorrect xpath provided: " + path , exception ) ; throw new IllegalArgumentException ( ) ; } }
Helper method to retrieve XML node value with provided xPath .