Parser JTidy(HTML Parser) How to

황제낙엽 2008.06.10 10:00 조회 수 : 437 추천:255

sitelink1  
sitelink2  
sitelink3 http://1 
sitelink4 http://ko 
sitelink5 http://jtidy.sourceforge.net/howto.html 
sitelink6 http://sitelink1 

You can use JTidy as an html checker/prettyprinter or as a DOM parser.

First of all, you will need to download a JTidy distribution. Inside it you will find a jtidy-{version}.jar, where {version} is the JTidy release number: this is the jar containing all the JTidy classes you need, and we will name it this simply jtidy.jar in the following how to. No other libraries are needed.

Now that you have JTidy you can use it in different ways.

JTidy executable

Run java -jar jtidy.jar {options} to access JTidy command line interface.

java -jar jtidy.jar -h will output a short help on jtidy command line with a few examples.

java -jar jtidy.jar -help-config will output all the available configuration options and java -jar jtidy.jar -show-config the current (default) values. .

Ant task

Detailed instructions on how to use the JTidy ant task can be found in JTidyTask javadocs.

JTidy API

The entry point for accessing JTidy functionalities is the org.w3c.tidy.Tidy class. This is a simple example of use:

                    Tidy tidy = new Tidy(); // obtain a new Tidy instancetidy.setXHTML(boolean xhtml); // set desired config options using tidy setters ...                           // (equivalent to command line options)tidy.parse(inputStream, System.out); // run tidy, providing an input and output stream                

Using parseDOM(java.io.InputStream in, java.io.OutputStream out) instead of parse() you will also obtain a DOM document you can parse and print out later using pprint(org.w3c.dom.Document doc, java.io.OutputStream out) (note that the JTidy DOM implementation is not fully-featured, and many DOM methods are not supported).

Starting from release r8, JTidy also provide a MessageListener interface you can implement to be notified for warning and errors in your html code. For details on advanced uses refer to jtidy javadocs.

번호 제목 글쓴이 날짜 조회 수
143 숫자 에 대응 되는 패턴의 형식화 #1 황제낙엽 2008.07.08 359
142 숫자를 통화 표기 형태로 변환하기 황제낙엽 2008.07.08 347
141 NumberFormat, DecimalFormat 사용예 황제낙엽 2008.07.08 402
140 파일의 내용을 읽어 String 객체로 만드는 함수 황제낙엽 2008.06.17 296
139 UTF형태 파일에서 BOM 제거하기 황제낙엽 2008.06.16 2243
138 불러온 txt파일의 Encoding을 알 수는 방법좀 가르쳐 주세요~ 황제낙엽 2008.06.16 388
137 FileFilter, FilenameFilter 클래스를 이용한 파일 또는 디렉토리 리스트 추출하기 황제낙엽 2008.06.16 493
136 정규식 사용예제 [2] 황제낙엽 2008.06.11 384
135 정규식 사용예제 [1] 황제낙엽 2008.06.11 436
134 StringBuffer vs String 황제낙엽 2008.06.10 314
133 작지만 강력한 HTML 파서, HtmlCleaner, html parser 황제낙엽 2008.06.10 398
132 Jericho HTML Parser 황제낙엽 2008.06.10 556
» JTidy(HTML Parser) How to 황제낙엽 2008.06.10 437
130 NekoHTML 샘플 예제 황제낙엽 2008.06.09 427
129 YGHTML Parser 0.1.1 샘플 예제 황제낙엽 2008.06.09 358
128 HTML Paser 의 종류 황제낙엽 2008.06.09 710
127 File 생성시 encoding 지정하기 (Unicode/utf-8 file 읽고 쓰기) 황제낙엽 2008.05.22 756
126 java String.replaceAll (String regex, String replacement) 쓸떄 조심할 것 황제낙엽 2008.05.22 424
125 java String.replaceAll 잘쓰기 황제낙엽 2008.05.22 429
124 간단한 DBConnection 프로그램 (JDBC) file 황제낙엽 2008.05.15 456