public static void printChildElements(Element parent, PrintStream out, boolean deep,
            String prefix)
    {
        out.print(prefix + "<" + parent.getNodeName());
        NamedNodeMap attrs = parent.getAttributes();
        Node node;
        for (int i = 0; i < attrs.getLength(); i++)
        {
            node = attrs.item(i);
            out.print(" " + node.getNodeName() + "=\"" + node.getNodeValue() + "\"");
        }
        out.println(">");

        // String data = getElementTextValueDeprecated(parent);
        String data = parent.getNodeValue();
        if (data != null && data.trim().length() > 0)
        {
            out.println(prefix + "\t" + data);
        }

        data = getElementCDataValue(parent);
        if (data != null && data.trim().length() > 0)
        {
            out.println(prefix + "\t<![CDATA[" + data + "]]>");
        }

        NodeList nodes = parent.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++)
        {
            node = nodes.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE)
            {
                if (deep)
                {
                    printChildElements((Element) node, out, deep, prefix + "\t");
                }
                else
                {
                    out.println(prefix + node.getNodeName());
                }
            }
        }

        out.println(prefix + "</" + parent.getNodeName() + ">");
    }