Element root = null; Document document = DocumentHelper.createDocument(root); root = document.addElement("Message","http://www.chinaport.gov.cn/ENT");
The above code solves the problem of invalid xmlns, and Message is the root node.
format.setNewLineAfterDeclaration(false);The above solves the second blank line problem.