不知道大家遇到这种问题没有
对于这样一个XML文件的格式<Model xmlns="http://www.esi-group.com/ns/VAOne" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd" name="" note="">
用dom4j写的时候,像rootElement.addAttribute()方法写的话是显示不出xmlns这个属性的
google了一下知道要这么写Element rootElement = document.addElement("Model",
"http://www.esi-group.com/ns/VAOne");
rootElement.addNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
rootElement
.addAttribute(
"xsi:schemaLocation",
"http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd");可问题出来了,这样一来为根元素制定了明空间,可下面的子节点都自动生成了个xmlns=""属性,就像这样 <?xml version="1.0" encoding="UTF-8" ?>
- <Model xmlns="http://www.esi-group.com/ns/VAOne" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd" name="" note="">
<Version xmlns="">1.5.0.6</Version>
<Spectra xmlns="" />
</Model>
请问一下怎么才能去掉子节点的这些多余属性呢?
第一次在csdn论坛发帖,也是刚刚工作,希望各位前辈帮帮忙,谢了。
对于这样一个XML文件的格式<Model xmlns="http://www.esi-group.com/ns/VAOne" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd" name="" note="">
用dom4j写的时候,像rootElement.addAttribute()方法写的话是显示不出xmlns这个属性的
google了一下知道要这么写Element rootElement = document.addElement("Model",
"http://www.esi-group.com/ns/VAOne");
rootElement.addNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
rootElement
.addAttribute(
"xsi:schemaLocation",
"http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd");可问题出来了,这样一来为根元素制定了明空间,可下面的子节点都自动生成了个xmlns=""属性,就像这样 <?xml version="1.0" encoding="UTF-8" ?>
- <Model xmlns="http://www.esi-group.com/ns/VAOne" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.esi-group.com/ns/VAOne http://www.esi-group.com/xml/schemas/VAOne/2010/VAOne.xsd" name="" note="">
<Version xmlns="">1.5.0.6</Version>
<Spectra xmlns="" />
</Model>
请问一下怎么才能去掉子节点的这些多余属性呢?
第一次在csdn论坛发帖,也是刚刚工作,希望各位前辈帮帮忙,谢了。
解决方案 »
- JAVA web 定时器
- hibernate 一对多 插入数据后获取id的疑问
- 配置xfire的mtom出现的错误,高手帮忙
- 拦截器使用session实现用户登录检查
- Spring安全控制Filter导致的no session
- WebSphere Studio application developer 开发
- AXIS deploy.wsdd 生成server-config.wsdd 出错
- 大家好~我想问的就是怎样做一张学生成绩报表的页面~
- 关于logic:equal标签的问题,解决重谢
- 在线程中使用log4j出现异常
- 求救求救Exception creating bean of class org.apache.struts.validator.DynaActionForm:
- spring 查询出现问题 queryForMap
element.addElement(name,url);//name为你的新定义元素节点名,URL就是你的名称空间。
当然,一般更多的是在根元素上定义缺省的名称空间,此时定义格式如下:
Element root=document.addElement(name,url);//name为你的新定义元素节点名,URL就是你的名称空间。
特别注意:不要通过类似于element.addNamspace("",url)这样的方式来为某个元素节点指定缺省名称空间,这样的做法就会出现你所描述的上述问题。