|
In order to add a new Child node to a Document-doc,
I try the following code.
doc.adoptNode(childNode);
doc.appendChild(childNode);
However this gives a ClassCastException as follows
while executing doc.adoptNode();
Exception in thread "main"
java.lang.ClassCastException:
org.apache.xerces.dom.D
ocumentImpl at org.apache.xerces.dom.DeferredAttrNSImpl.synchronizeChildren(Deferred AttrNSImpl.java:182) at org.apache.xerces.dom.AttrImpl.setOwnerDocument(AttrImpl.java:214) at org.apache.xerces.dom.NamedNodeMapImpl.setOwnerDocument(NamedNodeMapI mpl.java:421) at org.apache.xerces.dom.ElementImpl.setOwnerDocument(ElementImpl.java:1 93) at org.apache.xerces.dom.ParentNode.setOwnerDocument(ParentNode.java:226 ) at org.apache.xerces.dom.ElementImpl.setOwnerDocument(ElementImpl.java:1 91) at org.apache.xerces.dom.CoreDocumentImpl.adoptNode(CoreDocumentImpl.jav a:1181) at Test.parse(Test.java:49) at Test.main(Test.java:11) In case I use doc.importNode(childNode, true) a
NullPointerException is thrown while trying to retrieve the Doc elements.
Is this approach correct or do we need to do
something else?
Thanks,
Pranjal
|
- Re: Adding New Child node to a Document Pranjal Bhatnagar
- Re: Adding New Child node to a Document Isaac Shabtay
- Re: Adding New Child node to a Document Pranjal Bhatnagar
- RE: Adding New Child node to a Docum... Saurabh Shukla
- RE: Adding New Child node to a Document W�rfel Wolfgang
- RE: Adding New Child node to a Document Scott Moore
- Adding New Child node to a Document tom john
- Re: Adding New Child node to a Document Christian Geuer-Pollmann
