code: @Override
      public MessageEvent parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
                      throws XmlPullParserException, IOException {
          MessageEvent messageEvent = new MessageEvent();
          boolean done = false;
          while (!done) {
              int eventType = parser.next();
              if (eventType == XmlPullParser.START_TAG) {
                  if (parser.getName().equals("id"))
                      messageEvent.setStanzaId(parser.nextText());
                  if (parser.getName().equals(MessageEvent.COMPOSING))
                      messageEvent.setComposing(true);
                  if (parser.getName().equals(MessageEvent.DELIVERED))
                      messageEvent.setDelivered(true);
                  if (parser.getName().equals(MessageEvent.DISPLAYED))
                      messageEvent.setDisplayed(true);
                  if (parser.getName().equals(MessageEvent.OFFLINE))
                      messageEvent.setOffline(true);
              } else if (eventType == XmlPullParser.END_TAG) {
                  if (parser.getName().equals("x")) {
                      done = true;
                  }
              }
          }
  
          return messageEvent;
      }
docs: Parses a MessageEvent stanza (extension sub-packet).
  
  @param parser the XML parser, positioned at the starting element of the extension.
  @return a PacketExtension.
  @throws IOException
  @throws XmlPullParserException