import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import java.io.*;public class TestXml {
public TestXml() {
} public void save(){
try {
Element element = new Element("all-item");
Comment comment = new Comment("asdAsdasdasd");
Document doc = new Document(null);
ProcessingInstruction pi = new ProcessingInstruction
("xml-stylesheet", "href=\"bookList.html.xsl\" type=\"text/xsl\"");
doc.addContent(pi);
doc.setRootElement(element);
Element childItem = new Element("item");
Element itemChildTopic = new Element("topic");
Element itemChildContent = new Element("content");
childItem.addContent(itemChildTopic);
childItem.addContent(itemChildContent);
element.addContent(childItem);
OutputStream out = new FileOutputStream("d:/asdfgh.xml");
XMLOutputter outp = new XMLOutputter("", true, "GBK");
outp.output(doc, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
TestXml testXml = new TestXml();
testXml.save();
}}
web.xml里面的这句话 是用来验证文档的 具体什么意思自己查查看吧
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">发了好多贴呀
import org.jdom.input.*;
import org.jdom.output.*;
import java.io.*;public class TestXml {
public TestXml() {
} public void save(){
try {
Element element = new Element("all-item");
Comment comment = new Comment("asdAsdasdasd");
Document doc = new Document(null);
ProcessingInstruction pi = new ProcessingInstruction
("xml-stylesheet", "href=\"bookList.html.xsl\" type=\"text/xsl\"");
doc.addContent(pi);
doc.setRootElement(element);
Element childItem = new Element("item");
Element itemChildTopic = new Element("topic");
Element itemChildContent = new Element("content");
childItem.addContent(itemChildTopic);
childItem.addContent(itemChildContent);
element.addContent(childItem);
OutputStream out = new FileOutputStream("d:/asdfgh.xml");
XMLOutputter outp = new XMLOutputter("", true, "GBK");
outp.output(doc, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
TestXml testXml = new TestXml();
testXml.save();
}}
web.xml里面的这句话 是用来验证文档的 具体什么意思自己查查看吧
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">发了好多贴呀
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货