[jdom-interest] Is it possible in JDOM...?

Meghasyam Bokam mbokam at cs.nmsu.edu
Tue Oct 1 01:53:02 PDT 2002

Dear all,

  I am trying to construct a new subtree from the original xml tree.

I have :

  <eq />
  <ci> a </ci>
  <ci> b </ci>
  <ci> c </ci>

I need :

  <eq />
  <ci> a </ci>
  <ci> b </ci>

The code is :

//apply being the root element of our original tree

	List children = apply.getChildren();
	ListIterator iterator = children.listIterator(1);

	Element root = new Element("root");
	Element newElem = new Element("eq");
	root = root.addContent(newElem);
	for(int i=0; i<2; i++)
		Element nextElement = (Element) iterator.next();
		root = root.addContent(nextElement);

I am getting the error as :
    IllegalAddException : The ci already has an existing parent "apply"

Can anybody help me how to do get the subtree?

Thank You.


More information about the jdom-interest mailing list