0

QML XmlListModel を使用して、動作する XML フィードを表示しています。以下の説明タグに HTML が含まれているため、書式設定がオフになっていることを除きます。

<description>&lt;p&gt;&lt;a href="http://news.yahoo.com/north-korea-issues-military-threats-founders-birthday-000221193.html"&gt;&lt;img src="http://l1.yimg.com/bt/api/res/1.2/aSYzNa8DFZPW0FCALm20Yw--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9ODU7dz0xMzA-/http://media.zenfs.com/en_us/News/Reuters/2013-04-15T141115Z_1_CBRE93E0OEY00_RTROPTP_2_KOREA-NORTH.JPG"
    width="130" height="86" alt="North Korean soldiers, workers and students place flowers before statues of Kim Il-sung and Kim Jong-il at Mansudae in Pyongyang" align="left" title="North Korean soldiers, workers and students place flowers before statues
    of Kim Il-sung and Kim Jong-il at Mansudae in Pyongyang" border="0" /&gt;&lt;/a&gt;By Ju-min Park and Jack Kim SEOUL (Reuters) - North Korea made new threats of military action on Monday as the reclusive nation celebrated the anniversary of its founder&amp;#039;s
    birth, stoking tension on the peninsula with a new &amp;quot;ultimatum&amp;quot; to South Korea in the stand-off over its nuclear program. The latest statement from Pyongyang followed threats of nuclear attacks on the United States, South Korea and Japan,
    after new U.N. sanctions were imposed in response to the North&amp;#039;s latest nuclear test in February. ...&lt;/p&gt;&lt;br clear="all"/&gt;
</description>

<文字が XML で許可されて>いないため、文字が置き換えられてから HTML になると思います。

以下のモデルを使用していますが、説明に変更された HTML テキストが含まれている場合にいくつかの問題が発生することを除いて動作します。

XmlListModel {
    id: model
    property string feedUrl: rss.activeFeed
    source: "http://" + feedUrl
    query: "/rss/channel/item"
    property ListModel temp
    property int action
    XmlRole { name: "title"; query: "title/string()" }
    XmlRole { name: "link"; query: "link/string()"}
    XmlRole { name: "description"; query: "description/string()" }
}
4

1 に答える 1

0

HTML と長い URL を CDATA タグでラップしてみてください。XML は不正な文字を次のように除外します。

<description><![CDATA[

&lt;p&gt;&lt;a href="http://news.yahoo.com/north-korea-issues-military-threats-founders-birthday-000221193.html"&gt;&lt;img src="http://l1.yimg.com/bt/api/res/1.2/aSYzNa8DFZPW0FCALm20Yw--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTg2O3E9ODU7dz0xMzA-/http://media.zenfs.com/en_us/News/Reuters/2013-04-15T141115Z_1_CBRE93E0OEY00_RTROPTP_2_KOREA-NORTH.JPG"
    width="130" height="86" alt="North Korean soldiers, workers and students place flowers before statues of Kim Il-sung and Kim Jong-il at Mansudae in Pyongyang" align="left" title="North Korean soldiers, workers and students place flowers before statues
    of Kim Il-sung and Kim Jong-il at Mansudae in Pyongyang" border="0" /&gt;&lt;/a&gt;By Ju-min Park and Jack Kim SEOUL (Reuters) - North Korea made new threats of military action on Monday as the reclusive nation celebrated the anniversary of its founder&amp;#039;s
    birth, stoking tension on the peninsula with a new &amp;quot;ultimatum&amp;quot; to South Korea in the stand-off over its nuclear program. The latest statement from Pyongyang followed threats of nuclear attacks on the United States, South Korea and Japan,
    after new U.N. sanctions were imposed in response to the North&amp;#039;s latest nuclear test in February. ...&lt;/p&gt;&lt;br clear="all"/&gt;

]]></description>
于 2013-04-16T17:50:54.780 に答える