开发者

Appending a new node or a child node using Dom4j

I am s开发者_高级运维tuck at updating an existing XML document. I have to add another element to the root node. I need to append it, but using XMLWriter, it is overriding the object and all the old data is lost. How can I add another node to the exisitng document?

That is, appending. I am using the Dom4j library.


XMLWriter is not the way to go. You can append, delete or otherwise manipulate nodes quite easily using the methods in the Node class and its subclasses. For example:

Element root = document.getRootElement();
Element author = root.addElement("author");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜