public static String replaceNodeName(Document document, String containerNodeName, String childNodeNameToReplace, String childNodeNameReplacement) throws TransformerException {
        final NodeList containerNodes = document.getElementsByTagName(containerNodeName);
        if (containerNodes != null) {
            for (int i = 0; i < containerNodes.getLength(); i++) {
                Node containerNode = containerNodes.item(i);
                final NodeList childNodes = containerNode.getChildNodes();
                for (int j = 0; j < childNodes.getLength(); j++) {
                    Node childNode = childNodes.item(j);
                    if (Objects.equals(childNode.getNodeName(), childNodeNameToReplace)) {
                        document.renameNode(childNode, null, childNodeNameReplacement);
                    }
                }
            }
        }
        return getString(document);
    }
@Test
    public void replaceNodeName() throws Exception {
        final String replacement = "replacement";
        Document document = DOMParserUtil.getDocument(XML);
        
        DOMParserUtil.replaceNodeName(document, MAIN_NODE, TEST_NODE, replacement);
        
        final Map<Node, List<Node>> retrieved = DOMParserUtil.getChildrenNodesMap(document, MAIN_NODE, replacement);
        assertThat(retrieved).isNotNull();
        assertThat(retrieved).hasSize(1);
        
        List<Node> testNodes = retrieved.values().iterator().next();
        assertThat(testNodes).isNotNull();
        assertThat(testNodes).hasSize(1);
        assertThat(testNodes.get(0).getNodeName()).isEqualTo("replacement");
    }