설.현.아빠
HTMLCleaner를 이용한 HTML 파싱 본문
아...어렵다..게시판에서 글을 긁어오는 소스이다.. 난 게시판에 글을 적고 싶은디...ㅠㅠ
아래 사이트에서 HTML Cleaner의 다운로드가 가능하다.
http://htmlcleaner.sourceforge.net/download.php
작지만 강력한 HTML 파서, HtmlCleaner, html parser
http://blog.naver.com/tyboss/70030506248
http://greenweblog.tistory.com/105
package lee.hyeontae.KensCafe.GuestBook; import java.net.URL; import org.htmlcleaner.CleanerProperties; import org.htmlcleaner.HtmlCleaner; import org.htmlcleaner.SimpleXmlSerializer; import org.htmlcleaner.TagNode; import android.app.Activity; import android.os.Bundle; public class GuestBookListView extends Activity { @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); try { URL url; url = new URL("http://note.blueweb.co.kr/bluecgi/guestbook/guest.php?dbname=dodo49890"); HtmlCleaner cleaner = new HtmlCleaner(); CleanerProperties properties = cleaner.getProperties(); TagNode node = null; properties.setOmitComments(true); properties.setOmitDeprecatedTags(true); node = cleaner.clean(url); SimpleXmlSerializer se = new SimpleXmlSerializer(properties); //se.writeToFile(node, "abd.xml"); se.writeXmlToStream(node, System.out); } catch (Exception e) { e.printStackTrace(); } }} GuestBookListView.java GuestBookWrite.java GuestBookPage.java package lee.hyeontae.KensCafe.GuestBook; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.widget.TabHost; public class GuestPage extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("GuestBookList") .setIndicator("List") .setContent(new Intent(this, GuestBookListView.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))); tabHost.addTab(tabHost.newTabSpec("GuestBookWrite") .setIndicator("Write") .setContent(new Intent(this, GuestBookWrite.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))); } @Override protected void onDestroy() { super.onDestroy(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { return super.onKeyDown(keyCode, event); } }
'안드로이드 > Parser' 카테고리의 다른 글
Simple Java XMl Parser(SJXP) (0) | 2011.11.04 |
---|---|
안드로이드 XML PARSER 심플한 예제 (1) | 2011.02.11 |
안드로이드 htmlParser 이용한 로젠택배 조회 서비스 만들기. (0) | 2011.02.11 |
Data Feed / RSS 예제 (0) | 2011.02.11 |
[학습자료] 안드로이드에서 JSON 처리 방법 (3) | 2011.02.11 |