I am having an incredibly frustrating time attempting to remove comments
from a document. More specifically, an object in my system holds a
reference to an XML structure:
suite = document.getRootElement().element("suite");
I then process this node heavily, removing single elements and replacing
them with more complicated structures, as well as comment nodes:
fix(suite);
At the end of processing, I would like to remove all of the comments
from the document. This is proving to be next to impossible. I am
using the following code:
List comments = suite.selectNodes("//comment()");
for (Iterator it = comments.iterator(); it.hasNext(); ) {
((org.dom4j.Comment )it.next()).detach();
}
When I add the 'suite' element above to a document and output the
result, all of the comments are still in the document. I have tried
many, many variations of removing the nodes, including removing directly
from the content list, using the parent node 'remove()' method, and
gathering the comment node XPath expressions using getUniquePath and
processing them individually in a number of ways.
Does anyone have any advice as to why these comments are proving so
difficult to remove?
Thanks in advance,
Cory.
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user