title: NetworkUsage sample app Showing Error Parsing XML
body: <p>I run NetworkUsage sample project app on Android Studio, project builds issue free. However, when it runs on my device (NOT emulator), I get an <em>XmlPullParserException</em>. I have my phone connected to wifi and assigned correct permissions in manifest. when i do a debug, i trace it all the way to </p>
  
  <pre><code>parser.require(XmlPullParser.START_TAG, ns, "feed");  
  </code></pre>
  
  <p>that is where it stops. The parser processes the <em>inputStream</em> fetching data from </p>
  
  <pre><code>private static final String URL = "http://stackoverflow.com/feeds/tag?tagnames=android&amp;sort=newest";  
  </code></pre>
  
  <p>for some reason name parameter(in this case "feed") does not equal getName(), in this case <strong>html</strong>, and i dont know where it is getting <strong>html</strong> from. My knowledge on parsing xml and hmtl markup is very very limited and going through the motions of learning this aspect of programming and how it will integrate with future projects. i say this because my question might seem trivial to some. Thanks for the help</p>
  
  <pre><code>public class StackOverflowXmlParser {
  private static final String ns = null;
  
  // We don't use namespaces
  
  public List&lt;Entry&gt; parse(InputStream in) throws XmlPullParserException, IOException {
      try {
          XmlPullParser parser = Xml.newPullParser();
          parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
          parser.setInput(in, null);
          parser.nextTag();
          return readFeed(parser);
      } finally {
          in.close();
      }
  }
  
  private List&lt;Entry&gt; readFeed(XmlPullParser parser) throws XmlPullParserException, IOException {
      List&lt;Entry&gt; entries = new ArrayList&lt;Entry&gt;();
  
      parser.require(XmlPullParser.START_TAG, ns, "feed");
      while (parser.next() != XmlPullParser.END_TAG) {
          if (parser.getEventType() != XmlPullParser.START_TAG) {
              continue;
          }
          String name = parser.getName();
          // Starts by looking for the entry tag
          if (name.equals("entry")) {
              entries.add(readEntry(parser));
          } else {
              skip(parser);
          }
      }
      return entries;
  }
  
  // This class represents a single entry (post) in the XML feed.
  // It includes the data members "title," "link," and "summary."
  public static class Entry {....}
  
  // Parses the contents of an entry. If it encounters a title, summary, or link tag, hands them
  // off
  // to their respective &amp;quot;read&amp;quot; methods for processing. Otherwise, skips the tag.
  private Entry readEntry(XmlPullParser parser) throws XmlPullParserException, IOException {}
  
  // Processes title tags in the feed.
  private String readTitle(XmlPullParser parser) throws IOException, XmlPullParserException {}
  
  // Processes link tags in the feed.
  private String readLink(XmlPullParser parser) throws IOException, XmlPullParserException {}
  
  // Processes summary tags in the feed.
  private String readSummary(XmlPullParser parser) throws IOException, XmlPullParserException {}
  
  // For the tags title and summary, extracts their text values.
  private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {}
  
  // Skips tags the parser isn't interested in. Uses depth to handle nested tags. i.e.,
  // if the next tag after a START_TAG isn't a matching END_TAG, it keeps going until it
  // finds the matching END_TAG (as indicated by the value of "depth" being 0).
  private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {}
  </code></pre>
  
  <p>Here is the link to the project/android training section on parsing xml 
  <a href="https://developer.android.com/training/basics/network-ops/xml.html" rel="nofollow noreferrer">https://developer.android.com/training/basics/network-ops/xml.html</a></p>