Code example for Attributes

Methods: getValue

0
 
	@Override 
	public void onStartElement(String name, Attributes atts) {
        if (name.equals("comment")) {
            mCurrentComment = new Comment();
            mCurrentComment.setDrinkId(Integer.parseInt(atts.getValue("article_id").trim()));
            mCurrentComment.setUserId(Integer.parseInt(atts.getValue("user_id").trim()));
            mCurrentComment.setNickname(atts.getValue("nickname").trim());
 
            try { 
                Date created = CommentsParser.CreatedTime.parse(atts.getValue("created").trim());
                mCurrentComment.setCreated(DateFormat.format("yyyy-MM-dd", created));
            } catch (ParseException e) {
                mCurrentComment.setCreated(null);
            } 
 
            int rating = 0;
            if (!TextUtils.isEmpty(atts.getValue("rating").trim())) {
                rating = (int) Float.parseFloat(atts.getValue("rating").trim());
            } 
             
            mCurrentComment.setRating(rating);
        } 
	}