<!--输出XML-->String sql="select * from XXXXX"
ResultSet rs=stmt.executeQuery(sql);
String process="<?xml version=\"1.0\" encoding=\"gb2312\" ?><root>";
out.write(process);//IO输出流
while(rs.next()){
    String str="";
    str+="<data ";
     for(int i=1;i<rsmd.getColumnCount()+1;i++){
        str+=" ";
        str+="BBB";//这里可以是表的写段名rsmd.getColumnName(i);
        str+="=\"";        String _te=rs.getString(i);
         if(_te!=null) _te.trim();
          str+=_te;
          str+="\" ";
        }
        str+=" />\n";
        out.write(str); //toXML.write(str.getBytes());
        out.flush();
      }
      out.write("</root>");//toXML.write("</root>".getBytes());
      out.flush();<!----------------------------------------------->导入数据库中的例子.
<!--获得Node 或者Attribute-->
  public String[] getInitParamS(String fileName,String key,boolean isok)
      throws IOException,SAXException{    DOMParser parser=new DOMParser();
    parser.parse(fileName);
    Document dom=parser.getDocument();
    NodeList newKey=dom.getElementsByTagName(key);
    NamedNodeMap attributes;
    String newString[]=new String[newKey.getLength()];
    String _newString[]=null;    for(int i=0;i<newKey.getLength();i++){
      Node aNode=newKey.item(i);
      newString[i]=aNode.getFirstChild().getNodeValue().toString();
      attributes=aNode.getAttributes();
      _newString=new String[attributes.getLength()];
      for(int a=0;a<attributes.getLength();a++){
        Node theAttribute=attributes.item(a);
        _newString[a]=theAttribute.getNodeValue().toString();
      }
    }
    if(isok){
      return newString;
    }else{
      return _newString;
    }
  }<!--开始导入-->
String [] S_bbb = getInitParamS(String fileName,"BBB",false);
fro(int i=0;i<S_bbb.length;i++){
String sql="inser into XXX values("+S_bbb[i]=")";
ResultSet rs=stmt.executeQuery(sql);
}