I'm trying to drill down a few levels from the root element of a document and then remove an element. I obtain a reference to the element I want to remove plus its parent, and I call:
parentElement.remove(childElement);

I get an org.dom4j.IllegalAddException. What's interesting about the exception is that it describes the addition of the root element to a null branch. It's like dom4j doesn't know to stop before it gets to this point:
org.dom4j.IllegalAddException: The node "org.dom4j.tree.DefaultElement@8941f7 [Element: <wsdl:definitions uri: http://schemas.xmlsoap.org/wsdl/ attributes: [org
.dom4j.tree.DefaultAttribute@49d67c [Attribute: name targetNamespace value "urn:
other.root"]]/>]" could not be added to the branch "null" because: The Node alr
eady has an existing document: org.dom4j.tree.DefaultDocument@b4e29b [Document: name file:/C:/ALLDOCS/CODE/GENERAL/output/deploy/idea.wsdl]
at org.dom4j.tree.DefaultDocument.addNode(DefaultDocument.java:253)
at org.dom4j.tree.AbstractBranch.add(AbstractBranch.java:221)
at org.dom4j.tree.AbstractDocument.setRootElement(AbstractDocument.java:
166)
...

I tried catching this exception within my code by putting a try block around the remove() call, but that was just ignored.

So how do I go about removing an element within the DOM tree?




-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to