目录

chen 的个人博客

VX:TiAmo151028
Phone:13403656751
Email:zxydczzs@gmail.com

dom4j设置XML命名空间

附代码:

Java:

1        Document document= DocumentHelper.createDocument();
2        Element root = document.addElement("xml", "http://www.w3.org/1999/xhtml");
3        String requestXml = document.asXML();
4        System.out.println(requestXml);
5

pom.xml

1        <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
2        <dependency>
3            <groupId>org.dom4j</groupId>
4            <artifactId>dom4j</artifactId>
5            <version>2.1.1</version>
6        </dependency>

输出:

1<xml xmlns="http://www.w3.org/1999/xhtml"></xml>

标题:dom4j设置XML命名空间
作者:zzzzchen
地址:https://dczzs.com/articles/2021/07/28/1627437547369.html