code: public static Collection<String> parseMechanisms(XmlPullParser parser)
                      throws XmlPullParserException, IOException {
          List<String> mechanisms = new ArrayList<String>();
          boolean done = false;
          while (!done) {
              int eventType = parser.next();
  
              if (eventType == XmlPullParser.START_TAG) {
                  String elementName = parser.getName();
                  if (elementName.equals("mechanism")) {
                      mechanisms.add(parser.nextText());
                  }
              }
              else if (eventType == XmlPullParser.END_TAG) {
                  if (parser.getName().equals("mechanisms")) {
                      done = true;
                  }
              }
          }
          return mechanisms;
      }
docs: Parse the available SASL mechanisms reported from the server.
  
  @param parser the XML parser, positioned at the start of the mechanisms stanza.
  @return a collection of Stings with the mechanisms included in the mechanisms stanza.
  @throws IOException
  @throws XmlPullParserException