怎么样使用JDOM输出完整的XML文档?
怎么样使用JDOM输出完整的XML文档?
package myPackage;
import java.io.*;
import org.jdom.*;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class MyClass {
public static void main(String[] args) {
File f=new File("test.xml");
SAXBuilder saxb=new SAXBuilder();
XMLOutputter op=new XMLOutputter();
try {
Document xmldoc=saxb.build(f);
op.output(xmldoc, System.out);
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}