Difficulty Reading with Atom Reader


I tried making a parser for both RSS and Atom where RSS feed shows the headlines while Atom shows with images and description plus link. It seems my parser works only for RSS. Can you tell me why? Check this one:

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(); } }

Every time when I found this tutorial plus managing with MVC for myself, the results is impressive. However, when I try implementing a URL contains Atom feed and it didn't show up.


Its obvious the structure is different, you need 2 different parsers! Or 2 packed in one (don't really know how helpful will be that)


RSS 2.0:

<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>Example Feed</title> <description>Insert witty or insightful remark here</description> <link>http://example.org/</link> <lastBuildDate>Sat, 13 Dec 2003 18:30:02 GMT</lastBuildDate> <managingEditor>johndoe@example.com (John Doe)</managingEditor> <item> <title>Atom-Powered Robots Run Amok</title> <link>http://example.org/2003/12/13/atom03</link> <guid isPermaLink="false">urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</guid> <pubDate>Sat, 13 Dec 2003 18:30:02 GMT</pubDate> <description>Some text.</description> </item> </channel> </rss>

Atom 1.0:

<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Example Feed</title> <subtitle>Insert witty or insightful remark here</subtitle> <link href="http://example.org/"/> <updated>2003-12-13T18:30:02Z</updated> <author> <name>John Doe</name> <email>johndoe@example.com</email> </author> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry> <title>Atom-Powered Robots Run Amok</title> <link href="http://example.org/2003/12/13/atom03"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>Some text.</summary> </entry> </feed>

Comparison <a href="http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared#table" rel="nofollow">here</a>, the difference problem in your code is that on atom you have entry not item as in rss!


  • Difficulty Reading with Atom Reader
  • Type is not resolved for member “Microsoft.IdentityModel.Claims.ClaimsPrincipal,Microsoft.IdentityMo
  • VTK render window image to numpy array
  • Android : Parse using xmlpullparser
  • java.lang.NoSuchMethodError: java.lang.System.arraycopy using XmlPullParser with Robolectric
  • PHP Explode and Get_Url: Not Showing up the URL
  • Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedM
  • XmlPullParser get file from filesystem
  • Android XmlPullParser - how to parse this XML sample file?
  • One Note Api rejects Bearer Token, Error 401
  • How do I add some other audio to the muted section of an audio using ffmpeg?
  • Splitting text into paragraphs with regex JAVA
  • Haskell exceptions and unit testing
  • nginx on VirtualBox Ubuntu guest serves stale content [closed]
  • Accessing a csv file with D3 inside meteor
  • Unzip archive in .Net CORE 1.0
  • Streaming screenshots over WebRTC as a video stream from iOS
  • Ionic 2 storage is not cleaning up on uninstall - Only for signed APK
  • Play WS (2.2.1): post/put large request
  • Bad request using file_get_contents for PUT request in PHP
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • what is the difference between the asp.net mvc application and asp.net web application
  • Matrix multiplication with MKL
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Binding checkboxes to object values in AngularJs
  • How to push additional view controllers onto NavigationController but keep the TabBar?