Anthony Ikeda wrote:
> I know this may be a basic question, but I've tried every possible
> option I can think of. Simply put, all I'm trying to do, is add a

Then you need to think harder! ;) Just kidding. This problem
happens all of the time. There are a few problems that I see:

> public class headache{
>     public Element toXML(){
>         .....
>         return Element;
>     }
> }
> 
>     DocumentImpl doc = new DocumentImpl();
>     Element root = doc.createElement("root");
> 
>     headache h = new headache();
>     Element e = headache.toXML();
>     root.appendChild(e);

1) You're getting a WRONG_DOCUMENT_ERR because any node appended
   to a document must have been created using the same document
   factory. Therefore, your "headache#toXML" method must use
   the same document instance. Why don't you change the 
   prototype to pass in the document, like so:

     public Element toXML(Document factory);

> This returns the same. If I try to use importNode(node,true) on the
> calling class side:
> 
> rott.appendChild(doc.importNode(headache.toXML(),true));
> 
> I get:
> 
> Context log: path="" Error in qResults service() : null
>  java.lang.NoSuchMethodError
> 
>  at
> org.apache.xerces.dom.DocumentImpl.importNode(DocumentImpl.java:888)

Classpath problem. You are picking up the DOM Level 1 interfaces
before the DOM Level 2 interfaces (which added importNode). Once
this is fixed, the importNode should work but I wouldn't 
recommend it because this creates a copy of the imported node.
Very wasteful.

-- 
Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to