title: How to parse the below mentioned xml in android and store it in the class?
body: <p>I'm having an requirement where i need to parse the below xml and store it in class.</p>
  
  <pre><code>&lt;syncgroupsettings&gt;
          &lt;syncgroupset id = "sgMS" labelid = "lblMS" enabled = "YES" default = "OFF"&gt;
              &lt;syncgroup syncgroupname = "VISITS"/&gt;
              &lt;syncgroup syncgroupname = "CUSTOMERS"/&gt;
          &lt;/syncgroupset&gt;
  
          &lt;syncgroupset id = "sgAS" labelid = "lblAS" enabled = "YES" default = "ON"&gt;
              &lt;syncgroup syncgroupname = "SALESDOCS"/&gt;
              &lt;syncgroup syncgroupname = "ANALYTICS"/&gt;
          &lt;/syncgroupset&gt;
      &lt;/syncgroupsettings&gt;
  </code></pre>
  
  <p>So far what i have done was, i used to get the node value and simply adding it to arraylist of hashmap as shown below for other xml.</p>
  
  <pre><code>public class XmlParser {
  
      private static final String ns = null;
  
      /** This is the only function need to be called from outside the class */
      public static List&lt;ArrayList&lt;HashMap&gt;&gt; parse(Reader reader)
              throws XmlPullParserException, IOException {
          try{
              List&lt;ArrayList&lt;HashMap&gt;&gt; list = new ArrayList&lt;ArrayList&lt;HashMap&gt;&gt;();
              XmlPullParser parser = Xml.newPullParser();
              parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
              parser.setInput(reader);
              parser.nextTag();           
              return readLabels(parser);
          }finally{
  
          }
      }        
  
      /** This method read each country in the xml data and add it to List */
      private static List&lt;ArrayList&lt;HashMap&gt;&gt; readLabels(XmlPullParser parser)
              throws XmlPullParserException,IOException {
  
          List&lt;ArrayList&lt;HashMap&gt;&gt; list = new ArrayList&lt;ArrayList&lt;HashMap&gt;&gt;();
  
          parser.require(XmlPullParser.START_TAG, ns, "xml");
  
          while(parser.next() != XmlPullParser.END_TAG){
              if(parser.getEventType() != XmlPullParser.START_TAG){
                  continue;
              }
  
              String name = parser.getName();
              if(name.equals("labels")){
                  //do nothing
              }
              else if(name.equals("label"))
               {
                   list.add(readLabel(parser));
               }
              else
              {
                  skip(parser);
              }
          }       
          return list;
      }
  
      /** This method read a country and returns its corresponding HashMap construct */
      private static ArrayList&lt;HashMap&gt; readLabel(XmlPullParser parser)
              throws XmlPullParserException, IOException {
  
          parser.require(XmlPullParser.START_TAG, ns, "label");
  
          String labelid = parser.getAttributeValue(ns, "id");
          String textlan = "";
          String textval="";
  
          ArrayList&lt;HashMap&gt; al=new ArrayList&lt;HashMap&gt;();
          HashMap&lt;String, String&gt; hm = new HashMap&lt;String, String&gt;();
          while(parser.next() != XmlPullParser.END_TAG){
              if(parser.getEventType() != XmlPullParser.START_TAG){
  
                  continue;
              }
  
              String name = parser.getName();
               if(name.equals("text")) {
                  textlan = parser.getAttributeValue(ns,"language");
                  textval = parser.getAttributeValue(ns,"value");
                   String details =   "language : " + textlan  + "value : " + textval;
                   hm.put(labelid,details );
                   al.add(hm);
                   readText(parser);
               }
              else
               {
                  skip(parser);
              }
          }
          return al;
      }
  
  
      /** Process Capital tag in the xml data */    
      private static void readText(XmlPullParser parser)
              throws IOException, XmlPullParserException {
          parser.require(XmlPullParser.START_TAG, ns, "text");
          parser.nextTag();
      }
  
  
      private static void skip(XmlPullParser parser)
              throws XmlPullParserException, IOException {
          if (parser.getEventType() != XmlPullParser.START_TAG) {
              throw new IllegalStateException();
          }
          int depth = 1;
          while (depth != 0) {
              switch (parser.next()) {
              case XmlPullParser.END_TAG:
                  depth--;
                  break;
              case XmlPullParser.START_TAG:
                  depth++;
                  break;
              }
          }
       }
  }
  </code></pre>
  
  <p>But for this particular xml, i need to store it in the class. Could you please help me with this regard.</p>