First I hop you all don't mind if I move this discussion to the mailing
list, this is far to intreressting not to be included there.
> From: "Soumanjoy Das" <[EMAIL PROTECTED]>
> > Hi James,
> >
> > This is just a very elementary question where Christian and
> I are having
> > some confusion. I want to know this so as to clarify my
> concepts: When a
> > list of nodes is returned by .selectNodes(), and then I add
> a Node to the
> > List object, does that add the Node to the original document too?
>
> No absolutely not. e.g where should it add it? I could do
>
> List foos = doc.selectNodes( "//foo" );
>
> and find all kinds of different elements. Adding a new node
> to the list,
> where should it go?
>
> I agree though maybe it should be readonly - but sometimes
> people want to
> sort the results and so forth.
>
> If you want to add to the tree, find a node in the results
> you like and add
> it to its parent.
>
> Node node = (Node) foos.get(0);
> Element parent = node.getParent();
> parent.addElement( "somethingElse" );
Oki, this is all fine BUT
what happens if we do:
List foos = doc.selectNodes("//foo");
foos.add(1,doc.createElement("newElement"));
doc.setContent(foos);
Where does the "newElement" go?
Cheers Christian
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user