[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 :

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

I need :

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

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.

Meghasyam.




More information about the jdom-interest mailing list