From: "Barry Andrews" <[EMAIL PROTECTED]> > Hi, > There seems to be no way to remove or modify Comments of a Document > either in the org.dom4j package or the org.w3c.dom package. It seems that > this should be pretty basic, so why are there no methods? Does anyone know > how this can be done?
Document doc = ...; List comments = doc.selectNodes( "//comment()" ); for (Iterator iter = comments.iterator(); iter.hasNext(); ) { Comment comment = (Comment) iter.next(); comment.detach(); } If you're using a SAX parser to create the Document in the first place then it'll be more efficient to just filter out the SAX comment events. I've just patched the code in CVS so that you can easily filter out comments when parsing documents. SAXReader reader = new SAXReader(); reader.setIgnoreComments(true); Document doc = reader.read( "foo.xml" ); James ------- http://radio.weblogs.com/0112098/ __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com ------------------------------------------------------- This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev