私はこのRSSフィードを解析するために、AndroidのXML解析ヘルパー(android.util.Xml.parse(InputStream, Encoding, ContentHandler
)を使用しています:http://www.rssweather.com/wx/nz/christchurch/rss.php。取得しようとしているデータが入っているcontent:encoded
タグを認識していないようです。ここではXMLの構造は次のとおりです。Android XML.parse()コンテンツが見つかりません:エンコードされたタグ
<rss>
<channel>
<item>
<title>...</title>
<pubDate>...</pubDate>
// Other tags
<content:encoded>
<![CDATA[
(.... this is what I want to retrieve ...)
]]>
</content:encoded>
</item>
</channel>
</rsss>
これは私のコードです:私が間違っている
void parse(){
RootElement root = new RootElement("rss");
Element channel = root.getChild("channel");
Element item = channel.getChild("item");
Element contentEncoded = item.getChild("content", "encoded");
// Have also tried these two:
Element encoded = item.getChild("encoded");
Element content = item.getChild("content");
contentEncoded.setEndTextElementListener(new EndTextElementListener() {
public void end(String body) {
Log.d("Test", "Content found: " + body);
}
});
try {
Xml.parse(feedUrl.openConnection().getInputStream(),
Xml.Encoding.UTF_8, root.getContentHandler());
} catch (Exception e){
throw new RuntimeException(e);
}
}
? :)私は<item>
要素から、タイトルやpubDateなどの他のデータを問題なく取り出すことができます。唯一のコンテンツです:エンコードされたものです。
スティーブその問題... http://stackoverflow.com/questions/8193414/parsing-cdata-in-android –
ああ、面白そうです。私は読んで行き、それが問題を沸騰させるかどうかを見るでしょう。ありがとう –