我想生成:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
<common>
<sign>
<fitechFiller>admin</fitechFiller>
<fitechChecker>admin</fitechChecker>
<fitechPrincipal>admin</fitechPrincipal>
</sign>
</common>
</report>
添加Namespace ns_xml = Namespace.getNamespace(reportObj.getXmlns_Attr());
Namespace ns_xsi = Namespace.getNamespace("xsi", reportObj.getXmlnsxsi_Attr());
reportElement.setNamespace(ns_xml);
reportElement.addNamespaceDeclaration(ns_xsi);
后就生成了:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
<common xmlns="">
<sign>
<fitechFiller>admin</fitechFiller>
<fitechChecker>admin</fitechChecker>
<fitechPrincipal>admin</fitechPrincipal>
</sign>
</common>
</report>这样在common节点中添加了xmlns=""是我不想要的,改怎么处理呢???谢谢
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
<common>
<sign>
<fitechFiller>admin</fitechFiller>
<fitechChecker>admin</fitechChecker>
<fitechPrincipal>admin</fitechPrincipal>
</sign>
</common>
</report>
添加Namespace ns_xml = Namespace.getNamespace(reportObj.getXmlns_Attr());
Namespace ns_xsi = Namespace.getNamespace("xsi", reportObj.getXmlnsxsi_Attr());
reportElement.setNamespace(ns_xml);
reportElement.addNamespaceDeclaration(ns_xsi);
后就生成了:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://fitech-report.com/smis" xmlns:xsi="http://www.w3.org/2001/XMLSchema" reporttype="POINT" reportlayer="MAIN">
<common xmlns="">
<sign>
<fitechFiller>admin</fitechFiller>
<fitechChecker>admin</fitechChecker>
<fitechPrincipal>admin</fitechPrincipal>
</sign>
</common>
</report>这样在common节点中添加了xmlns=""是我不想要的,改怎么处理呢???谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货