private static void printDom(String prefix, Node node) {

        String text = node.getNodeValue();
        if (text != null && !text.isEmpty()) {
            System.out.println(prefix + " value = \"" + text + "\"");
        }
        NamedNodeMap attributes = node.getAttributes();
        if (attributes != null) {
            for (int i = 0; i < attributes.getLength(); i++) {
                Node attr = attributes.item(i);
                System.out.println(prefix +
                        " attr = \"" + attr.getNodeName() + "\"" +
                        " value = \"" + attr.getTextContent().toString() + "\" ");
            }
        }

        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            printDom(prefix + node.getNodeName() + ":", children.item(i));
        }
    }