简体   繁体   中英

Update XML node but keep the XML file format and comments info intact

What is the best practice for XML change/update/add new info using Java, in a way so that Info node/comments still remain intact and formatting also. Please guide....

Can we achieve this in JixB?

XML comments are treated as nodes like any other XML node (elements, etc.) and the whitespace that formats the XML nicely is treated as Text nodes. So your question is really how to maintain those comment and text nodes as you use something like JixB to construct your Java objects from the XML.

I don't don't know whether JixB maintains the nested comment and text nodes so that when you persist the data as XML the comments and formatting remains the same.

If you're going directly against the Dom, though, you can know that those extra nodes exist in the DOM and take care to maintain them as you update the XML as well as insert new comment and text nodes to add that formatting style around newly added data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM