docs: private static JSONArray parse(XMLTokener x, JSONArray ja) throws JSONException {
  
          char c;
          int i;
          String s;
          Object t;
  
          // Test for and skip past these forms:
          //      <!-- ... -->
          //      <!   ...   >
          //      <![  ... ]]>
          //      <?   ...  ?>
          // Report errors for these forms:
          //      <>
          //      <=
          //      <<
  
          while (true) {
              t = x.nextContent();
              if (t == XML.LT) {
                  t = x.nextToken();
                  if (t instanceof Character) {
  
                      // <!
  
                      if (t == XML.BANG) {
                          c = x.next();
                          if (c == '-') {
                              if (x.next() == '-') {
                                  x.skipPast("-->");
                              }
                              x.back();
                          } else if (c == '[') {
                              t = x.nextToken();
                              if (t.equals("CDATA") && (x.next() == '[')) {
                                  x.nextCDATA();
                              } else {
                                  throw x.syntaxError("Expected 'CDATA['");
                              }
                          } else {
                              i = 1;
                              do {
                                  t = x.nextMeta();
                                  if (t == null) {
                                      throw x.syntaxError("Missing '>' after '<!'.");
                                  } else if (t == XML.LT) {
                                      i += 1;
                                  } else if (t == XML.GT) {
                                      i -= 1;
                                  }
                              } while (i > 0);
                          }
                      } else if (t == XML.QUEST) {
  
                          // <?
  
                          x.skipPast("?>");
                      } else if (t == XML.SLASH) {
  
                          // Close tag </
  
                          t = x.nextToken();
                          if (ja == null) {
                              throw x.syntaxError("Mismatched close tag '" + t + "'");
                          }
                          if (!t.equals(ja.get(0))) {
                              throw x.syntaxError("Mismatched '" + ja.get(0) + "' and '" + t + "'");
                          }
                          if (x.nextToken() != XML.GT) {
                              throw x.syntaxError("Misshaped close tag");
                          }
                          return null;
                      } else {
                          throw x.syntaxError("Misshaped tag");
                      }
  
                      // Open tag <
  
                  } else {
                      JSONArray newja = new JSONArray();
                      JSONObject attributes = new JSONObject();
                      if (ja != null) {
                          ja.put(newja);
                      }
                      newja.put(t);
                      t = null;
                      for (;;) {
                          if (t == null) {
                              t = x.nextToken();
                          }
                          if (t == null) {
                              throw x.syntaxError("Misshaped tag");
                          }
                          if (!(t instanceof String)) {
                              break;
                          }
  
                          // attribute = value
  
                          s = (String)t;
                          t = x.nextToken();
                          if (t == XML.EQ) {
                              t = x.nextToken();
                              if (!(t instanceof String)) {
                                  throw x.syntaxError("Missing value");
                              }
                              attributes.accumulate(s, t);
                              t = null;
                          } else {
                              attributes.accumulate(s, "");
                          }
                      }
                      if (attributes.length() > 0) {
                          newja.put(attributes);
                      }
  
                      // Empty tag <.../>
  
                      if (t == XML.SLASH) {
                          if (x.nextToken() != XML.GT) {
                              throw x.syntaxError("Misshaped tag");
                          }
                          if (ja == null) {
                              return newja;
                          }
  
                          // Content, between <...> and </...>
  
                      } else if (t == XML.GT) {
                          parse(x, newja);
                          if (ja == null) {
                              return newja;
                          }
                      } else {
                          throw x.syntaxError("Misshaped tag");
                      }
                  }
              } else {
                  if (ja != null) {
                      ja.put(t);
                  }
              }
          }
      }