[jdom-interest] Recursively Modifying the JDOM before output.

Gary Montgomery Gary.Montgomery at G11N.COM
Fri Jun 1 11:44:26 PDT 2001


Hi all-

Just started working with Jdom a couple days ago. Addding XML access to my
app went with out a hitch,
Writing the XML back out to file works great also. But recursing over the
jdom tree and updating the text in nodes
before I write the xml back out to file gave me a hell of a time. What I had
originally was this:


	element.setText(getConfig(element.getName()));
/*  element just lost it's referrence to it's children ???? */
	_iterator.set(element);


After much experimenting I changed it to:

	List children = element.getChildren();
	element.setText(getConfig(element.getName()));
	element.setChildren(children);
/*  element has it's children and the recursion continues happily */
	_iterator.set(element);


This works, but I sure would like to understand why setText() causes element
to loose it's children. Or if there is something
else going on here, what it is.

Btw, I'm working with Beta 6 and jdk1.3 on NT.

Thanks,
Gary Montgomery 











More information about the jdom-interest mailing list