class DOMParserUtil {

    public static void replaceNodeText(Document document, String containerNodeName, String nodeName, String toReplace, String replacement) {
        asStream(document.getElementsByTagName(containerNodeName))
                .forEach(containerNode -> asStream(containerNode.getChildNodes())
                        .filter(childNode -> Objects.equals(nodeName, childNode.getNodeName()) && Objects.equals(toReplace, childNode.getTextContent()))
                        .forEach(childNode -> childNode.setTextContent(replacement)));
    }

    private  DOMParserUtil();

}