class XMLUtil extends AbstractCaller {

    @Description("Returns a list values by xpath.<br>" +
            "<b>content</b> - xml document<br>" +
            "<b>xpath</b> - path to list<br>" +
            "Example:<br/>" +
            "#{getListByXPath(content, xpath)}")
    @UtilityMethod
    public List<String> getListByXPath(String content, String xpath) {
        NodeList nodes = getNodesByXPath(content, xpath);
        if (nodes.getLength() == 0) {
            return Collections.emptyList();
        }

        List<String> result = new ArrayList<>();
        for(Node elem : nodeListToList(nodes, x -> x.getNodeType() != Node.COMMENT_NODE)) {
            if (!hasOnlyTextNode(elem)) {
                throw new EPSCommonException("The node has child nodes." + System.lineSeparator() + nodeToString(elem));
            }
            result.add(elem.getTextContent());
        }

        return result;
    }

}