if (nnm.getLength()>0) text = text + " " + nnm.toString();
if (nnm.getLength()>0) { StringBuffer buff = new StringBuffer(); Node attr = nnm.item(0); buff.append(attr.getNodeName()).append("=").append(attr.getNodeValue()); for (int i=1; i<nnm.getLength();i++) { attr = nnm.item(i); buff.append(" ").append(attr.getNodeName()).append("=").append(attr.getNodeValue()); } text = text + " " + buff.toString(); }
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {            if (value instanceof Node) {                Node node = (Node) value;                String text = value.toString();                int type = node.getNodeType();//                System.out.println("Type: " + type + ": " + node.toString());                switch (type) {                    case Node.ATTRIBUTE_NODE: text = "ATTRIBUTE_NODE"; break;                    case Node.CDATA_SECTION_NODE: text = "CDATA_SECTION_NODE"; break;                    case Node.COMMENT_NODE: text = "COMMENT_NODE"; break;                    case Node.ELEMENT_NODE:                        text = "<" + node.getNodeName();                        NamedNodeMap nnm = node.getAttributes();                        if (nnm.getLength()>0) text = text + " " + nnm.toString();                        text = text + ">";                        break;                    case Node.TEXT_NODE: text = node.getNodeValue(); break;                    default: value = "Type: " + node.getNodeType() + node.toString();                }                value = text.trim();            }            return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);        }