android.util.Xml.parse(InputStream, Encoding, ContentHandler
このRSSフィードを解析するためにAndroidのXML解析ヘルパー()を使用しています:http: //www.rssweather.com/wx/nz/christchurch/rss.php。content:encoded
取得しようとしているデータが含まれているタグを認識していないようです。XMLの構造は次のとおりです。
<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>
: )titleやpubDateなどの要素から他のデータを問題なく取得できます。私を逃れるのはcontent:encodedだけです。