[jdom-interest] newbie - help with document level comments (TYPO in orginal message) -

Frank Walinsky fwalinsky at extol.com
Mon May 14 13:30:52 PDT 2001

I came up with an answer.  If there's another way please let me know.

I create the document with a dummy root element("rootw") and add the
comments to the document just as before.
I also create another element("root") that will become the actual root
element and add all elements and their children to it.
Just before I output the document:
      List work = xmlDoc.getMixedContent();
This gets the comments at the top

Sorry, but I had a typo in the original message- "root.addContent(..."
should have been - "xmlDoc.addContent(.....

I'm creating an XML document using the Beta 6 release.  I create the
document with - "Document xmlDoc = new Document(root);"
Interspersed with adding elements to the "root" and children to these
elements, I add comments at the document level with - "xmlDoc.addContent(new
Comment("doc level comment"));.  When the process finishes all the document
level comments appear at the end of the file.   I want the comments to
appear at the beginning of the document before the "root" element.  Is this
possible?  I haven't figured out any way to do it.   Thanks in advance for
any help.

More information about the jdom-interest mailing list