public static Set<Element> runXPath(Document XMLDoc, String xPath) {
        Set<Element> result = new HashSet<Element>();
        try {
            XPathExpression query = XPATH_FACTORY.newXPath().compile(xPath);
            Object elements = query.evaluate(XMLDoc, XPathConstants.NODESET);
            NodeList nodes = (NodeList) elements;
            for (int i = 0; i < nodes.getLength(); i++)
                result.add((Element) nodes.item(i));
        } catch (NumberFormatException e1) {
            e1.printStackTrace();
        } catch (XPathExpressionException e1) {
            e1.printStackTrace();
        } catch (Exception e1) {
            e1.printStackTrace();
        }

        return result;
    }