我试图将元素添加到我的xml文档中,所以它看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<students>
</students>
但是,它最终看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<students/>
这是我正在使用的代码:
// results is the new XML document I created using DocumentBuilder.newDocument();
Element root = results.createElement("students");
results.appendChild(root);
怎么看起来不像我想要的那样?
Java dom是根据xml规范实现的,并且根据定义实现:没有内容的元素被认为是空的:https : //www.w3.org/TR/REC-xml/#sec-starttags。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句