Notice
Recent Posts
Recent Comments
Link
관리 메뉴

설.현.아빠

HTMLCleaner를 이용한 HTML 파싱 본문

안드로이드/Parser

HTMLCleaner를 이용한 HTML 파싱

설.현.아빠 2011. 2. 25. 16:29





아...어렵다..게시판에서 글을 긁어오는 소스이다.. 난 게시판에 글을 적고 싶은디...ㅠㅠ

http://lugway.tistory.com/63





아래 사이트에서 HTML Cleaner의 다운로드가 가능하다.

http://htmlcleaner.sourceforge.net/download.php




작지만 강력한 HTML 파서, HtmlCleaner, html parser

http://blog.naver.com/tyboss/70030506248



HtmlCleaner를 이용하여 xml 생성하기

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);

}


}





Comments