Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] to change element text (keeping children)

Jason Hunter

2006-11-11

Replies:

You can call getContent(), loop to find the right Text node, and replace
it inline.

-jh-

Munirul Islam wrote:
> Hi!
>
> I am trying to change the text of an element in a dom keeping its children.
>
> n.setText("b");
>
> Here, the setText method changes the text deleting n's children.
>
> I tried the following code:
>
> Element m = new Element("Element");
> m = (Element) n.clone();
> n.setText("b");
> n.setContent(m.getChildren);
>
> ends up giving illegalAddException.
>
> Does anyone have a solution to this problem?
>
> Thanks!
> ==============================
> Munirul Islam
> PhD Student
> Department of Computer Science
> Wayne State University
> Detroit,MI-48202,USA
> email: munirul@(protected)
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.