마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 Jsoup 리스트뷰 파싱(Parsing) 관련입니다.

0 추천
안녕하세요. 파싱관련 질문입니다.
 
Github 사이트에서 이슈게시판의 제목과 제목을 클릭했을 때 내용을 이런식으로 리스트뷰로 파싱을 하고 싶은데요.
    (이슈의 제목을 파싱해서 리스트뷰로)
   (파싱한 제목을 클릭했을 때 상세페이지에는 제목과 내용)
 
제가 이 사이트를 통해 예제를 봤는데 특히 아래 코드 부분에서 어떻게 적용해야할지를 잘 모르겠어요. Github 이슈 게시판에서 제가 원하는 title까지 depth가 아래처럼 10개 정도 되는데... 얘네들을 전부 다 고려해줘야 하나요?  아니면 더 쉽게 하는 방법이 있을까요?
 
- wrapper
- site
- container
- repository-with-sidebar repo-container new-discussion-timeline
- repository-content context-loader-container
- issues-listing
- table-list table-list-bordered table-list-issues js-navigation-container js-active-navigation-container
- read table-list-item js-navigation-item js-issue-row
- table-list-cell issue-title
- issue-title-link js-navigation-open
 
여기 보시면 for문으로 계속 돌리던데 10개 depth에 대해서 모두 for문을 돌려야 할까요 ㅠㅠ? 
아시는 분들 답변좀 부탁드립니다. 감사합니다.
@Override
		protected Void doInBackground(Void... params) {
			// Create an array
			arraylist = new ArrayList<HashMap<String, String>>();
 
			try {
				// Connect to the Website URL
				Document doc = Jsoup.connect(url).get();
				// Identify Table Class "worldpopulation"
				for (Element table : doc.select("table[class=worldpopulation]")) {
					
					// Identify all the table row's(tr)
					for (Element row : table.select("tr:gt(0)")) {
						HashMap<String, String> map = new HashMap<String, String>();
						
						// Identify all the table cell's(td)
						Elements tds = row.select("td");
						
						// Identify all img src's
						Elements imgSrc = row.select("img[src]");
						// Get only src from img src
						String imgSrcStr = imgSrc.attr("src");
						
						// Retrive Jsoup Elements
						// Get the first td
						map.put("rank", tds.get(0).text());
						// Get the second td
						map.put("country", tds.get(1).text());
						// Get the third td
						map.put("population", tds.get(2).text());
						// Get the image src links
						map.put("flag", imgSrcStr);
						// Set all extracted Jsoup Elements into the array
						arraylist.add(map);
					}
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
 
			return null;
		}

 

 

양갱드로이드 (120 포인트) 님이 2015년 3월 23일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...