docs: @Override
      public AMPExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
                      throws XmlPullParserException, IOException {
          final String from = parser.getAttributeValue(null, "from");
          final String to = parser.getAttributeValue(null, "to");
          final String statusString = parser.getAttributeValue(null, "status");
          AMPExtension.Status status = null;
          if (statusString != null) {
              try {
                  status = AMPExtension.Status.valueOf(statusString);
              } catch (IllegalArgumentException ex) {
                  LOGGER.severe("Found invalid amp status " + statusString);
              }
          }
  
          AMPExtension ampExtension = new AMPExtension(from, to, status);
  
          String perHopValue = parser.getAttributeValue(null, "per-hop");
          if (perHopValue != null) {
              boolean perHop = Boolean.parseBoolean(perHopValue);
              ampExtension.setPerHop(perHop);
          }
  
          boolean done = false;
          while (!done) {
              int eventType = parser.next();
              if (eventType == XmlPullParser.START_TAG) {
                  if (parser.getName().equals(AMPExtension.Rule.ELEMENT)) {
                      String actionString = parser.getAttributeValue(null, AMPExtension.Action.ATTRIBUTE_NAME);
                      String conditionName = parser.getAttributeValue(null, AMPExtension.Condition.ATTRIBUTE_NAME);
                      String conditionValue = parser.getAttributeValue(null, "value");
  
                      AMPExtension.Condition condition = createCondition(conditionName, conditionValue);
                      AMPExtension.Action action = null;
                      if (actionString != null) {
                          try {
                              action = AMPExtension.Action.valueOf(actionString);
                          } catch (IllegalArgumentException ex) {
                              LOGGER.severe("Found invalid rule action value " + actionString);
                          }
                      }
  
                      if (action == null || condition == null) {
                          LOGGER.severe("Rule is skipped because either it's action or it's condition is invalid");
                      } else {
                          AMPExtension.Rule rule = new AMPExtension.Rule(action, condition);
                          ampExtension.addRule(rule);
                      }
                  }
              } else if (eventType == XmlPullParser.END_TAG) {
                  if (parser.getName().equals(AMPExtension.ELEMENT)) {
                      done = true;
                  }
              }
          }
  
          return ampExtension;
      }