public void traverse(Node child,DefaultMutableTreeNode parent){
        int type = child.getNodeType();
        if(type == Node.ELEMENT_NODE){
            Element elm = (Element)child;
            DefaultMutableTreeNode node = new DefaultMutableTreeNode("<" + elm.getTagName() + ">");
            parent.add(node);
            if(elm.hasChildNodes()){
                NodeList list = elm.getChildNodes();
                for(int i=0; i<list.getLength(); i++){
                    traverse(list.item(i),node);
                }
            }
        }
        else if(type == Node.TEXT_NODE){
            Text t = (Text)child;
            String textContent = t.getTextContent().trim();
            if(!textContent.equals("")){
                DefaultMutableTreeNode node = new DefaultMutableTreeNode(textContent);
                parent.add(node);
            }
        }
    }