dom4j设置XML命名空间
附代码:
Java:
Document document= DocumentHelper.createDocument();
Element root = document.addElement("xml", "http://www.w3.org/1999/xhtml");
String requestXml = document.asXML();
System.out.println(requestXml);
pom.xml
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.1</version>
</dependency>
输出:
<xml xmlns="http://www.w3.org/1999/xhtml"></xml>