code: public static JSONObject toJSONObject(String string) throws JSONException {
          return (JSONObject)parse(new XMLTokener(string), false, null, false);
      }
docs: Convert a well-formed (but not necessarily valid) XML string into a
  JSONObject using the JsonML transform. Each XML tag is represented as
  a JSONObject with a "tagName" property. If the tag has attributes, then
  the attributes will be in the JSONObject as properties. If the tag
  contains children, the object will have a "childNodes" property which
  will be an array of strings and JsonML JSONObjects.
  
  Comments, prologs, DTDs, and <code>&lt;[ [ ]]></code> are ignored.
  @param string The XML source text.
  @return A JSONObject containing the structured data from the XML string.
  @throws JSONException Thrown on error converting to a JSONObject