0

現在、Yahoo! から取得している RSS ニュース フィードは次のとおりです。

<item>
    <title>
    Cheapest Stocks in Egypt Post Best Rally in Year on Army Control
    </title>
    <link>http://us.rd.yahoo.com/finance/external/bloomberg/rss/SIG=13gf1d488/*http://www.bloomberg.com/news/2013-10-01/cheapest-stocks-in-egypt-post-best-rally-in-year-on-army-control.html?cmpid=yhoo
    </link>
    <description>
    [at Bloomberg] - Egyptian stocks posted their best quarter in a year as increased political stability combined with the world’s cheapest equities lured investors.
    </description>
    <guid isPermaLink="false">yahoo_finance/1833836173</guid>
    <pubDate>Tue, 01 Oct 2013 22:00:00 GMT</pubDate>
</item>

descriptionUI コントロールにコンテンツを表示するのはとても簡単です。UI のルック アンド フィール (フォント サイズ、フォントの色) は自分で決めることができます。

ただし、Google からコンテンツを取得する場合はさらに難しくなります。

これが例です

<item>
    <title>Genting, UMW weigh on KLCI - The Star Online</title>
    <link>http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNE006d3wlqjgGfQAqGV8S4VFtQY3g&url=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx
    </link>
    <guid isPermaLink="false">tag:news.google.com,2005:cluster=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx</guid>
    <pubDate>Wed, 25 Sep 2013 01:21:04 GMT</pubDate>
    <description>
        <table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"></font></td><td valign="top" class="j"><font style="font-size:85%;font-family:arial,sans-serif"><br /><div style="padding-top:0.8em;"><img alt="" height="1" width="1" /></div><div class="lh"><a href="http://news.google.com/news/url?sa=t&amp;fd=R&amp;usg=AFQjCNE006d3wlqjgGfQAqGV8S4VFtQY3g&amp;url=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx"><b>Genting, UMW weigh on KLCI</b></a><br /><font size="-1"><b><font color="#6f6f6f">The Star Online</font></b></font><br /><font size="-1">KUALA LUMPUR: <b>Malaysia&#39;s</b> blue chips extended their losses for third day on Wednesday, with the FBM KLCI opened down nearly five points on mild selling of Genting <b>Bhd</b>, UMW and BAT, in line with the subdued Asian bourses. At 9am, the KLCI was down 4.42 <b>...</b></font><br /><font size="-1" class="p"></font><br /><font class="p" size="-1"><a class="p" href="http://news.google.com/news/more?ncl=dQyXEqkX7SN2KKM&amp;ned=us"><nobr><b>and more&nbsp;&raquo;</b></nobr></a></font></div></font></td></tr></table>
    </description>
</item>

ご覧のとおり、 にdescriptionはさまざまな HTML タグが付属していますが、これは私の関心の対象外です。フォーマット情報ではなく、プレーンなコンテンツにのみ関心があります。

目的を達成できる簡単な方法はありますか?

4

2 に答える 2

1

このHtmlクラスにはfromHtml()、文字列からタグを削除するメソッドがあります。

String noHtml = Html.fromHtml(HTML_STRING).toString();

ここを参照してください: http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)

于 2013-10-02T12:28:49.427 に答える
0

XSLT を使用して xml 入力を xml 出力に変換できます。この場合、説明に一致するテンプレート マッチャーを作成し、それ以降は説明タグが終了するまでテキストのみを出力にコピーします。

于 2013-10-02T12:21:30.917 に答える