Code example for JSONArray

Methods: getJSONObject, length

0
        String nodeType;
        String searchType;
        String substrStr = substr ? "true" : "false";
        Logger.info("Building xpath selector from attr " + attr + " and constraint " + constraint + " and substr " + substrStr);
        String selOut = "s";
        for (int i = 0; i < path.length(); i++) {
            try { 
                pathObj = path.getJSONObject(i);
                nodeType = pathObj.getString("node");
                searchType = pathObj.getString("search");
            } catch (JSONException e) {
                throw new AndroidCommandException("Error parsing xpath path obj from JSON"); 
            } 
            try { 
                nodeType = AndroidElementClassMap.match(nodeType);
            } catch (UnallowedTagNameException e) {
                throw new AndroidCommandException(e.getMessage());
            } 
            if (searchType.equals("child")) {
                s = s.childSelector(s);
                selOut += ".childSelector(s)";