This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How do I retain the comments? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How do I retain the comments?" Watch "How do I retain the comments?" New topic

How do I retain the comments?

John Cogan
Ranch Hand

Joined: Jan 22, 2003
Posts: 32
I am parsing a documents using:
DOMParser parser = new DOMParser();
current = parser.getDocument();
the xml document looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- English message catalogue for Web Portal 3 -->
<catalogue xml:lang='en'>
<message key='copywrite.message'>Service powered by Spectel</message>
<!-- Generic Form Buttons -->
<message key='common.button.submit'>Login Current</message>
<message key='common.button.reset'>Reset</message>
<message key='common.button.back'>Back</message>
However, when I come to printing out the document again, the comments are lost. Is there any way of retaining them?
Best regards,

----------------<br />SCJP, SCWCD
John Cogan
Ranch Hand

Joined: Jan 22, 2003
Posts: 32
I have discovered the answer to this:
case Node.COMMENT_NODE: {
needs to be included in the print out function.
Best regards,
It is sorta covered in the JavaRanch Style Guide.
subject: How do I retain the comments?
It's not a secret anymore!