일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- PLSQL
- 전자정부프레임워크
- Eclipse
- WebLogic
- jQuery
- PHP
- MFC
- sencha touch
- jsr 296
- phonegap
- rowspan
- iBATIS
- Android
- JSON
- tomcat
- MySQL
- Struts
- appspresso
- ibsheet
- GPS
- Spring
- Google Map
- swingx
- Ajax
- node.js
- JDOM
- dock
- oracle
- 선택적조인
- 가우스
Archives
- Today
- Total
Where The Streets Have No Name
JDom을 이용한 XMLOutputter 본문
import java.io.File;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
public class XMLOutputterDemo2 {
public static void main(String[] args) {
try {
SAXBuilder b = new SAXBuilder(false); // true -> validate
// Create a JDOM document.
Document doc = b.build(new File("e:/people.xml"));
// Create an output formatter, and have it write the doc.
//new XMLOutputter().output(doc, System.out);
XMLOutputter xo = new XMLOutputter();
Format f = xo.getFormat();
f.setEncoding("UTF-8");
f.setIndent(" ");
f.setLineSeparator("\r\n");
f.setTextMode(Format.TextMode.TRIM);
xo.setFormat(f);
xo.output(doc, System.out);
} catch (JDOMException jex) {
System.out.print("PARSE ERROR: " + jex.getMessage());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}