stylesheet怎么加我也不清楚。至于导出,目前很多数据库产商都提供了XDK。
我用的是Oracle的XDK,它也支持其它数据库的,如MySQL等。
可以直接导出XML,也可以用XML插入DB记录。
去下一个吧,里面有文档的。

解决方案 »

  1.   

    sql2k
    use 
    select * from table FOR XML RAWxmlDoc.createProcessingInstruction("xml:stylesheet", "type=\"text/xsl\" href=\"simple.xsl\"")
      

  2.   

    我用jdom做的 运行一下看看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();
      }}
    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();
      }}这是结果
    <?xml version="1.0" encoding="GBK"?>
    <?xml-stylesheet href="bookList.html.xsl" type="text/xsl"?>
    <all-item>
    <item>
    <topic />
    <content />
    </item>
    </all-item>
      

  3.   

    哪位可以给我一个javaXML数据导出的例子看看啊???
      

  4.   

    javaXML数据导出的例子import java.sql.*;
    import org.w3c.dom.*;
    import org.apache.xerces.dom.*;
    import org.apache.xml.serialize.*;
    import java.io.*;
    public class SimpleXMLData{

    public static final String JDBCURL="jdbc:odbc:yang";

    public static String JDBCRIVER="sun.jdbc.odbc.JdbcOdbcDriver";

    public static final String SQL="SELECT * FROM Customer";

    public static final String OUTPUTFILE="Customer.xml";

    public static void main(String args[]){

    try{
    Class.forName(JDBCRIVER).newInstance();
    Connection conn=DriverManager.getConnection(JDBCURL);
    Statement statement=conn.createStatement();
    ResultSet customerRs=statement.executeQuery(SQL);

    Document xmlDoc=buildCustomerXML(customerRs);

    File outputFile=new File(Customer.xml);

    printDOM(xmlDoc,outputFile);
    conn.close();    }catch(Exception e){
        System.out.println("Really Poor exception handling:"+e.toString());
       }
    }

    private static Document buildCustomerXML(ResultSet _customerRs)
    throws Exception{

    Document xmlDoc=new DocumentImpl();

    Element rootElement=xmlDoc.createElement("Customer");
    xmlDoc.appendChild(rootElement);
    while(_customerRs.next()){

    Element customer=xmlDoc.createElement("Customer");

    customer.setAttribute("CustomerID",_customerRs.getString("CustomerID"));

    Element firstName=xmlDoc.createElement("CustomerName");
    Element lastName=xmlDoc.createElement("CustomerAddress");

    firstName.appendChild(xmlDoc.createTextNode(
    _customerRs.getString("CustomerName")));
    lastName.appendChild(xmlDoc.createTextNode(
    _customerRs.getString("CustomerAddress")));

    customer.appendChild(firstName);
    customer.appendChild(lastName);

    rootElement.appendChild(customer);

    }
    return xmlDoc;
    }

    private static void printDOM(Document _xmlDoc,File _outputFile)
    throws Exception{

    OutputFormat outputFormat=new OutputFormat("XML","UTF-8",true);

    FileWriter fileWriter=new FileWriter(_outputFile);

    XMLSerializer xmlSerializer=new XMLSerializer(
    fileWriter,outputFormat);

    xmlSerializer.asDOMSerializer();
    xmlSerializer.serialize(_xmlDoc.getDocumentElement());
    }
    }
      

  5.   

    CREATE TABLE [Customer](
    [CustomerID] [nchar ](5) COLLATE Chinese_PRC_CI_AS NOT NULL ,
    CompanyName [nvarchar] (40) COLLATE Chinese_PRC_CI_AS NOT NULL ,
    [CustomerAddress] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
    [ContactTitle] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
    [Address] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
    [City] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
    [Region] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
    [PostalCode] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
    [Country] [nvarchar] (15) COLLATE Chinese_PRC_CI_AS NULL ,
    [Phone] [nvarchar] (24) COLLATE Chinese_PRC_CI_AS NULL ,
    [Fax] [nvarchar] (24) COLLATE Chinese_PRC_CI_AS NULL 
    )