class XmlUtilsImpl implements XmlUtils {

    @Override
    public String getSubNodeText(Node parentNode, String subNodeName, boolean allowNone) throws
            XPathExpressionException, XmlSearchException
    {
        Node subNode = (Node) xPath.evaluate("./" + subNodeName, parentNode, XPathConstants.NODE);
        if (subNode != null)
        {
            return subNode.getTextContent();
        }
        if(allowNone)
        {
            return null;
        }
        throw new XmlSearchException(String.format("Failed to find subnode: %1$s", subNodeName));
    }

}