私が構築している Android アプリに Google Books API を使用しています。これは XML ファイルのサンプルです
<dc:description>This trilogy includes &quot; The Hitchhiker&#39;s Guide to the Galaxy&quot; , &quot; TheRestaurant at the End of the Universe&quot; , &quot; Life, Universe and Everything&quot; and &quot; So Long ...</dc:description>
<dc:format>590 pages</dc:format>
<dc:format>book</dc:format>
これは、説明を抽出するために使用しているコードの一部です
if ( entry.getElementsByTagName( "dc:description" ).item( 0 ) != null ) {
Element d = ( Element ) entry.getElementsByTagName( "dc:description" )
.item( 0 );
b.setDescription( d.getFirstChild( ).getNodeValue( ) );
}
問題は、HTML.fromHtml(Str) 関数を使用すると、最初の HTML エンティティでテキストが切り取られることです (したがって、この例では単に
この三部作には
Android の外で同じコードを実行すると、問題なく動作し、少なくともエスケープ文字を含む文字列が表示されます。
This trilogy includes " The Hitchhiker's Guide to the Galaxy" , " TheRestaurant at the End of the Universe" , " Life, Universe and Everything" and " So Long ...
これを手動でアプリに追加すると、 HTML.fromHtml() は正常に動作するので、問題は Android のパーサーの実装にあると思います。
同様の問題は、Android で xml ファイルの html をデコードすることです。ファクトリの検証を false に設定しようとしましたが、RSS フィードであるため、HTML ルート要素を宣言できません (この投稿で提案されているように)。