use dom4j, you can easily manipulate a Document object. some methods you may have interest -- Element.addAttribute() Element.setText() DocumentHelper.createElement() DocumentHelper.createDocument() DocumentHelper.createCDATA() Node.detach() Element.selectNodes() Element.selectSingleNode() Document.selectNodes() Document.selectSingleNodes() Element.clearContent() ...