jdbc将数据导出到xml中

时间:2012-11-18 21:13:02

标签: java sql xml jdbc

  

可能重复:
  Java: How to Indent XML Generated by Transformer
  jdbc export to xml - declaration showing standalone = no

      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transformer = factory.newTransformer();
      String outputPathname = "output.xml";
      StreamResult result = new StreamResult(new File(outputPathname));
      Source source = new DOMSource(dataDoc);
      transformer.transform(source, result);

我需要使用jdbc将数据导出到特定的结构化xml文档中。我正在使用解析方法。我需要顶部显示

    <?xml version="1.0" standalone="yes"?> 

但是,文件创建实际显示

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>. 

如何修改代码以获得所需的表单?

0 个答案:

没有答案