Code example for Document

Methods: renameNode

0
    private void renameAttrToTag(Document document, Node node) throws DOMException {
        if (node.getNodeName().equals("attr")) {
            String tag = node.getAttributes().getNamedItem("tag").getNodeValue();
 
            if (!tag.equals("?")) {
                document.renameNode(node, null, "tag" + tag);
            } 
        } 
    } 
     
    private void renameTagToAttr(Document document, Node node) throws DOMException {
        NamedNodeMap attr = node.getAttributes();
 
        if (attr != null) {
            Node tagAttr = attr.getNamedItem("tag");
 
            if (tagAttr != null) {
                String tag = "tag" + tagAttr.getNodeValue();
 
                if (!tag.equals("?") && tag.equals(node.getNodeName())) {
                    document.renameNode(node, null, "attr");