code: private static void stringify(JSONArray ja, StringBuffer b) throws JSONException {
  
          int i;
          JSONObject jo;
          String k;
          Iterator<String> keys;
          int len;
          Object o;
          Object v;
  
          // Emit <tagName>
  
          b.append('<');
          b.append(ja.get(0));
          o = ja.opt(1);
          if (o instanceof JSONObject) {
  
              // Loop thru the attributes.
  
              jo = (JSONObject)o;
              keys = jo.keys();
              while (keys.hasNext()) {
                  k = keys.next().toString();
                  v = jo.get(k).toString();
                  b.append(' ');
                  b.append(k);
                  b.append("=\"");
                  b.append(XML.escape((String)v));
                  b.append('"');
              }
              i = 2;
          } else {
              i = 1;
          }
          len = ja.length();
  
          if (i >= len) {
              b.append("/>");
          } else {
              b.append('>');
              while (i < len) {
                  v = ja.get(i);
                  if (v instanceof JSONArray) {
                      stringify((JSONArray)v, b);
                  } else {
                      b.append(XML.escape(v.toString()));
                  }
                  i += 1;
              }
              b.append("</");
              b.append(ja.get(0));
              b.append('>');
          }
      }
docs: Reverse the JSONML transformation, making an XML text from a JSONArray.<p>
  
  @param ja a JSONArray
  @param b a string buffer in which to build the text
  @throws JSONException if something goes wrong