Parser JTidy(HTML Parser) How to

황제낙엽 2008.06.10 10:00 조회 수 : 772 추천: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.

번호 제목 글쓴이 날짜 조회 수
146 사용팁 황제낙엽 2008.07.24 697
145 문자열 처리 - StringTokenizer 와 String.split() 황제낙엽 2008.07.08 657
144 숫자의 형식화 #1(Part-1)-java.text.NumberFormat 황제낙엽 2008.07.08 713
143 숫자 에 대응 되는 문자의 형식화 #2 황제낙엽 2008.07.08 704
142 숫자 에 대응 되는 패턴의 형식화 #1 황제낙엽 2008.07.08 724
141 숫자를 통화 표기 형태로 변환하기 황제낙엽 2008.07.08 693
140 NumberFormat, DecimalFormat 사용예 황제낙엽 2008.07.08 684
139 파일의 내용을 읽어 String 객체로 만드는 함수 황제낙엽 2008.06.17 531
138 UTF형태 파일에서 BOM 제거하기 황제낙엽 2008.06.16 2540
137 불러온 txt파일의 Encoding을 알 수는 방법좀 가르쳐 주세요~ 황제낙엽 2008.06.16 622
136 FileFilter, FilenameFilter 클래스를 이용한 파일 또는 디렉토리 리스트 추출하기 황제낙엽 2008.06.16 761
135 정규식 사용예제 [2] 황제낙엽 2008.06.11 673
134 정규식 사용예제 [1] 황제낙엽 2008.06.11 727
133 StringBuffer vs String 황제낙엽 2008.06.10 480
132 작지만 강력한 HTML 파서, HtmlCleaner, html parser 황제낙엽 2008.06.10 678
131 Jericho HTML Parser 황제낙엽 2008.06.10 820
» JTidy(HTML Parser) How to 황제낙엽 2008.06.10 772
129 NekoHTML 샘플 예제 황제낙엽 2008.06.09 601
128 YGHTML Parser 0.1.1 샘플 예제 황제낙엽 2008.06.09 621
127 HTML Paser 의 종류 황제낙엽 2008.06.09 933