//生成一条处理指令
Document jdom=new Document(new Element("root"));
ProcessingInstruction pi = new ProcessingInstruction
("xml-stylesheet","type='text/xsl'href='form.xsl'");
jdom.addContent(pi);
可是我为什么总是不能把那行放在root element的前边呢?总是在后边,在后边用IE就不能显示,放到前边就可以了。谢谢。
---------------------------------------------------------------
自己动手封装一下就可以了。
public static void OutputDocToFile(Document doc, String xslpath,
String encoding, String filePath) {
//setup this like outputDocument
try {
XMLOutputter outputter = new XMLOutputter(" ", true, encoding);
FileWriter out = new FileWriter(filePath);
out.write("
");
}
outputter.output(doc.getRootElement(), out);
out.close();
}
catch (java.io.IOException e) {
e.printStackTrace();
}
}