Java Mailing List Archive

http://www.junlu.com/

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

Re: [jdom-interest] retrieving the children of an element as text

Jason Hunter

2006-09-13

Replies:

I'd recommend xmlOutputter.outputString(mainelement.getContent()).

You could also output the entire mainelement with
outputString(mainelement) and then rip off the outer tags manually.

-jh-

Fabrizio Lippolis wrote:
> Hi,
>
> I have an element and I want to retrieve a String which contains the
> children of my element including their text. For example if I have
> mainelement in this way
>
> <mainelement>
>   <one>one</one>
>   <two>two</two>
> </mainelement>
>
> then I want to get
>
> <one>one</one>
> <two>two</two>
>
> I should also respect the formatting so that if I have
>
> <mainelement>
>   <one>one</one><two>two</two>
> </mainelement>
>
> I should get
>
> <one>one</one><two>two</two>
>
> Any suggestion please?
>
> Best regards,
> Fabrizio
>
> _______________________________________________
> 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.