java - How to retrieve an Element mixed children as text (JDOM) -


i have xml following:

<documentation>     value must <i>bigger</i> other. </documentation> 

using jdom, can following text structures:

document d = new saxbuilder().build( new stringreader( s ) ); system.out.printf( "gettext:          '%s'%n", d.getrootelement().gettext() ); system.out.printf( "gettextnormalize: '%s'%n", d.getrootelement().gettextnormalize() ); system.out.printf( "gettexttrim:      '%s'%n", d.getrootelement().gettexttrim() ); system.out.printf( "getvalue:         '%s'%n", d.getrootelement().getvalue() ); 

which give me following outputs:

gettext:          '     value must  other. ' gettextnormalize: 'this value must other.' gettexttrim:      'this value must  other.' getvalue:         '     value must bigger other. ' 

what wanted content of element string, namely, "this value must <i>bigger</i> other.". getvalue() comes close removes <i> tag. guess wanted innerhtml xml documents...

should use xmloutputter on contents? or there better alternative?

i'd should change document

<documentation>   <![cdata[this value must <i>bigger</i> other.]]> </documentation> 

in order adhere xml specification. otherwise <i> considered child element of <documentation> , not content.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -