Fri, 26 Oct 2007 16:20:57 +0200, /Spaan, Henk/:

As far as I know there is no objection against having a comment between the document type definition and the document element. So why can't I insert a comment before an existing document element with xerces.

        Element root = doc.getDocumentElement();
        doc.insertBefore(root, doc.createComment("My Comment"));

You need to exchange the places of the Node.insertBefore() arguments:

   doc.insertBefore(doc.createComment("My Comment"), root);

See the specification:

http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-952280727

--
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to