title: Parsing specific XML data from webURL - Android
body: <p>I would like to parse only one specific River data.
  From this website: <a href="http://www.arso.gov.si/xml/vode/hidro_podatki_zadnji.xml" rel="nofollow noreferrer">http://www.arso.gov.si/xml/vode/hidro_podatki_zadnji.xml</a></p>
  
  <p>My code below extract all Rivers:</p>
  
  <p>ParseApplication.java;</p>
  
  <pre><code>public class ParseApplication {
  
      private String xmlData; // XML file we are processing
      private ArrayList&lt;Application&gt; applications;
  
      public ParseApplication(String xmlData) {
          this.xmlData = xmlData;
          this.applications = new ArrayList&lt;Application&gt;();
      }
  
      public ArrayList&lt;Application&gt; getApplications() {
          return applications;
      }
  
      public boolean process()
      {
          boolean status = true;
          Application currentRecord = null;
          boolean inEntry = false;
          String textValue = "";
  
          try {
              XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
              factory.setNamespaceAware(true);
              XmlPullParser parser = factory.newPullParser();
              parser.setInput(new StringReader(this.xmlData));
              int eventType = parser.getEventType();
  
              while(eventType != XmlPullParser.END_DOCUMENT) {
                  String tagName = parser.getName();
                  switch (eventType) {
                      case XmlPullParser.START_TAG:
                          Log.d("ParseApplications", "Starting tag for " + tagName);
                          if (tagName.equalsIgnoreCase("postaja")) {
                              Log.d("ParseApplication", "Create application item");
                              inEntry = true;
                              currentRecord = new Application();
                          }
                          break;
  
                      case XmlPullParser.TEXT:
                          textValue = parser.getText(); // data itself, used in End_Tag
                          break;
  
                      case XmlPullParser.END_TAG:
                          Log.d("ParseApplication", "Ending tag for " + tagName);
  
                          if (inEntry) {
                              if (tagName.equalsIgnoreCase("postaja")) {
                                  // Save the record and set entry to false
                                  Log.d("ParseApplication", "Store Application With Name " + currentRecord.getReka());
                                  this.applications.add(currentRecord);
                                  inEntry = false;
                              } else if (tagName.equalsIgnoreCase("reka")) {
                                  currentRecord.setReka(textValue); // TextValue already updated
                              } else if (tagName.equalsIgnoreCase("pretok")) {
                                  currentRecord.setPretok(textValue);
                              } else  if (tagName.equalsIgnoreCase("datum")) {
                                  currentRecord.setDatum(textValue);
                              }
                          }
  
                          break;
  
                      default:
  
                          break;
                  }
  
                  eventType = parser.next();
              }
  
          } catch(Exception e) {
              status = false;
              e.printStackTrace();
          }
          return status;
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <p>application.java</p>
  
  <pre><code>public class Application {
  
      private String reka;
      private String pretok;
      private String datum;
  
      public String getReka() {
          return reka;
      }
  
      public void setReka(String reka) {
          this.reka = reka;
      }
  
      public String getPretok() {
          return pretok;
      }
  
      public void setPretok(String pretok) {
          this.pretok = pretok;
      }
  
      public String getDatum() {
          return datum;
      }
  
      public void setDatum(String datum) {
          this.datum = datum;
      }
  
      @Override
      public String toString() {
          return "Reka: " + this.getReka() + "\n" +
                  "Pretok: " + this.getPretok() + " m3\n" +
                  "Datum: " + this.getDatum();
      }
  }
  </code></pre>
  
  <p>How do I parse one specific XML River data only?</p>