Just tried childElement.detach(). Get the same exception. Have already
null-checked the child element, the parent, etc. --
"is the element to be removed null? false"
At 0844 20.11.02 -0500, David D. Lucas wrote
Instead of doing a remove, why not just call childElement.detach(); ?
Also, are you certain that childElement is not null?
Just a few changes and try again.
ORIGINAL MESSAGE:
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
- [dom4j-user] trying to remove a nested element Mitch Gitman
- Re: [dom4j-user] trying to remove a nested element David D. Lucas
- Re: [dom4j-user] trying to remove a nested element Mitch Gitman
- Re: [dom4j-user] trying to remove a nested ele... David D. Lucas
- Re: [dom4j-user] trying to remove a nested element Thierry Hanser
- Re: [dom4j-user] trying to remove a nested element James Strachan