xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon <Gordon.Po...@cs.tcd.ie>
Subject RE: problem removing a child node from a node
Date Wed, 04 Jun 2003 18:29:56 GMT
That works perfectly now.
Thanks for your help.
Gordon.


At 14:16 04/06/2003 -0400, you wrote:

> >>>>> "GP" == Gordon  <Gordon.Power@cs.tcd.ie> writes:
>
>GP> hey.  I have a problem removing a child node from a
>GP> node. Specifically, I'm trying to remove an Element from a
>GP> Document.  My code is:
>
>GP>     Element elmt =doc.getElementById( id ); if( elmt == null ){ }
>GP> else{ Element discard = doc.removeChild(elmt); }
>
>GP> This gives me a compile error:
>
>         found   : org.w3c.dom.Node
>         required: org.w3c.dom.Element
>                  discard = doc.removeChild(elmt);
>
>GP> I don't understand this because elmt is an Element and not a Node,
>GP> and Node is a superinterface of Element anyway.  Can anyone
>GP> explain this? I am using Batik 1.1.1 and jdk1.3.1 Thanks.
>
>     'discard' must be an Element. removeChild returns a Node.  Also
>you don't want to call 'removeChild' on doc I think you want to call
>it on elmt's parent (unless elmt is the root element of the document).
>
>      elmt.getParent().removeChild(elmt);  // From memory.

Mime
View raw message