私は次のようなXMLを持っています:
<documentation>
This value must be <i>bigger</i> than the other.
</documentation>
JDOMを使用すると、次のテキスト構造を取得できます。
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() );
これにより、次の出力が得られます。
getText: '
This value must be than the other.
'
getTextNormalize: 'This value must be than the other.'
getTextTrim: 'This value must be than the other.'
getValue: '
This value must be bigger than the other.
'
私が本当に欲しかったのは、要素のコンテンツを文字列、つまり。として取得することでした"This value must be <i>bigger</i> than the other."
。getValue()
近づきますが、<i>
タグを削除します。innerHTML
XMLドキュメントのようなものが欲しかったと思います...
コンテンツにXMLOutputterを使用する必要がありますか?または、より良い代替手段はありますか?