XML : Extract xml attributes based on other attributes

I'm exploring XmlPullParser from http://developer.android.com/training/basics/network-ops/xml.html .

How can I read in value 90 from type3 and value 25 from type4 using conditional operators? Many thanks!

  <record timestamp="SOME TIME">      <field type="type1" value="59"/>      <field type="type2" value="44"/>      <field type="type3" value="90"/>      <field type="type4" value="25"/>  </record>    xmlPullParser.require(START_TAG, ns, "record");  while (xmlPullParser.next() != END_TAG)  {      if (xmlPullParser.getEventType() != START_TAG)      {          continue;      }      String field = xmlPullParser.getAttributeValue(null, "field");      if (type == "NPSI_PM10")      {          NPSI_PM10 = xmlPullParser.getAttributeValue(null, "value");      }      else if (type == "NPSI_PM10")      {          NPSI_PM25 = xmlPullParser.getAttributeValue(null, "value");      }      else      {          Skip(xmlPullParser);      }  }    

No comments:

Post a Comment