Typically, with dom4j, you work with the live lists.
List elements = test.elements();
elements.add( elements.indexOf( refNode ), newNode );
Maybe a tad more verbose, but you get the flexibility of using
java.util.List methods to do whatever you please.
-bob
On Sat, 20 Oct 2001, Amber, Zhao Yuan Yuan wrote:
> hi,
>
> I have a problem using dom4j to insert a new node into a specific position
> in the tree.
>
> This is because the insertBefore(Node newNode, Node refNode) is not defined
> in com.dom4j.Node interface,
> but only implemented in "org.dom4j.dom.DOMElement", which is derived from
> "org.dom4j.tree.DefaultElement".
>
>
> But the default implementation of dom4j seems to be creating DefaultElement
> instead of DOMElement.
> If you get an object from method like
> Element test = Element.clone() or
> Element test = DOMDocument.getRootElement();
>
> You can't cast test into DOMElement, because internally it is created as
> DefultElement.
> Therefore, you can't do a test.insertBefore(newNode, refNode) on test,
> because inserBefore() is only supported in DOMElement level.
>
> I have checked dom4j.Node interface and found insertBefore() is not defined
> there.
> I think insertBefore is a very important feature that has been define in DOM
> Node, so I think it should
> be included into the dom4j.Node interface.
>
>
> Anyone encounter similia problem and knows a way to round about this?
>
>
> thx,
> amber
>
>
> _______________________________________________
> dom4j-dev mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-dev
>
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev