<P>Didn't we once wrote such a thing? It's pretty simple. You use an Iterator:
<P>approach a: a utility method - 
<P>void moveContent(Element src, Element dst) {<BR>&nbsp;List srcList=src.getContent(), dstList=dst.getContent();<BR>&nbsp;Iterator it=srcList.iterator();<BR>&nbsp;while (it.hasNext())<BR>&nbsp;Object ob=it.next();<BR>&nbsp;it.remove();<BR>&nbsp;dstList.add(ob);<BR>}</P>
<P>approach b would be to change ContentList.addAll(index,collection), so that if collection is a ContentList whose parent is NOT null, any object is removed from it (through the Iterator) before it is added to the destination list.</P>
<P>The first approach can be applied right away - just copy&amp;paste (I didn't try to compile/run it though) - no changes to the code base needed.</P>
<P>Noam.</P>
<P>&nbsp;<B><I>Jason Hunter <JHUNTER@SERVLETS.COM></I></B>wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Yes, there should be a convenience method for that. It's my goal to see<BR>one added.<BR><BR>-jh-<BR><BR>Phillip Rhodes wrote:<BR>&gt; <BR>&gt; I want to move the content of Element A to Element B<BR>&gt; <BR>&gt; Example<BR>&gt; <BR>&gt; Element elementA = getElementMethod();<BR>&gt; Element elementB = new Element("newelement");<BR>&gt; List listA = elementA.getContent();<BR>&gt; elementB.getContent().addAll(listA);<BR>&gt; <BR>&gt; The following will generate an error since the Elements, Text, CData<BR>&gt; objects have not been detached from the parent (elementA). While I know I<BR>&gt; can loop through the list, and test for the type of object it is and call<BR>&gt; the detach method, I wonder if there is a easier way. Don't you think<BR>&gt; there should be a convenience method somewhere to do this type of operation?<BR></BLOCKQUOTE><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/finance/mailsig/new/*http://finance.yahoo.com">Yahoo! Finance</a> - Get real-time stock quotes