RSS フィードが見出しを表示し、Atom が画像と説明とリンクを表示する、RSS と Atom の両方のパーサーを作成してみました。私のパーサーは RSS に対してのみ機能するようです。なぜか教えてくれますか?これを確認してください:
public void Get_Parse_Feed(String URL_link, Input_Streamer_Class is, List<String> headlines, List<String> links)
{
try
{
// URL
is = new Input_Streamer_Class();
/*
*
* Reserved URLS:
* --> http://feeds.pcworld.com/pcworld/latestnews
* --> http://feeds2.feedburner.com/boy-kuripot
* --> http://feeds2.feedburner.com/phcreditcardpromos
* --> http://feeds.feedburner.com/blogspot/MKuf
* --> http://googleblog.blogspot.com/atom.xml
*
*/
is.Set_URL(URL_link);
// Set XML pull factory.
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser xpp = factory.newPullParser();
// Picking up input stream...
xpp.setInput(is.Get_Input_Stream(is.Get_URL()), "UTF_8");
// Check for inside item.
boolean insideItem = false;
// Pick event type. (START_TAG, END_TAG, etc.)
int eventType = xpp.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT)
{
if(eventType == XmlPullParser.START_TAG)
{
if(xpp.getName().equalsIgnoreCase("item"))
{
insideItem = true;
} else if(xpp.getName().equalsIgnoreCase("title")) {
if(insideItem)
{
headlines.add(xpp.nextText()); // --> Extract the headline.
}
} else if(xpp.getName().equalsIgnoreCase("link")) {
if(insideItem)
{
links.add(xpp.nextText()); // --> Extract the link of article.
}
}
} else if((eventType == XmlPullParser.END_TAG) && xpp.getName().equalsIgnoreCase("item")) {
insideItem = false;
}
eventType = xpp.next(); // --> Move to the next element.
}
} catch(MalformedURLException e) {
e.printStackTrace();
} catch(XmlPullParserException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
}
このチュートリアルを見つけて MVC で自分自身を管理するたびに、その結果は印象的です。しかし、Atom フィードを含む URL を実装しようとすると、表示されませんでした。