@Test
public void test3() throws UnsupportedEncodingException {
NutMap data = NutMap.NEW();
data.setv("aaa","111");
data.setv("bbb","222");
String oper = Xmls.mapToXml("person", data);
Document xml = Xmls.xml(new ByteArrayInputStream(oper.getBytes("UTF-8")));
Element root = xml.getDocumentElement();
Element sign_ele = xml.createElement("ddd");
root.appendChild(sign_ele);
String dd = Xmls.mapToXml("test", Xmls.asMap(root));
System.out.println(dd);
}
输出:
<?xml version="1.0" encoding="utf-8"?>
<test>
<aaa>111</aaa>
<bbb>222</bbb>
</test>
我想要的结果为:
<?xml version="1.0" encoding="utf-8"?>
<test>
<aaa>111</aaa>
<bbb>222</bbb>
<ddd>222</ddd>
</test>
请问这是算一个bug还是正常的?我应该如何实现空的元素转换为xml