Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jspÉú³ÉxmlÎļþʾÀý

<£¥@ page contentType="text/html; charset=gb2312" £¥>
<£¥@ page language="java"£¥>
<£¥@ page info="database handler"£¥>
<£¥@ page import="java.io.*"£¥>
<£¥@ page import="java.lang.*"£¥>
<£¥@ page import="java.util.*"£¥>
<£¥@ page import="java.sql.*"£¥>
<£¥@ page import="javax.servlet.*"£¥>
<£¥@ page import="javax.servlet.http.*"£¥>
<html>
<head>
<meta content="text/html; charset=gb2312" http-equiv="content-type">
</head>
<body>
<£¥
int i=0;
String temp=null;
String parCode = request.getParameter("code");
String strSql;
try{
Connection con;
Statement stmt;
ResultSet rs;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:oracle:thin:@192.168.15.248:1521:ycdb";
con=DriverManager.getConnection(url,"webcfcquery","kill859");
//out.println("<center>jdbcÁ¬½ÓOracleÊý¾Ý¿â</center><br><br>");
stmt=con.createStatement();
strSql = "select account_holder,description from account_holder ";
if(parCode!=null)
strSql += " where account_holder='"+ parCode +"'";
rs=stmt.executeQuery(strSql);
FileOutputStream fo=new FileOutputStream("/usr/local/tomcat/webapps/vehicles/treasurer_voucher.xml");
PrintStream so = new PrintStream(fo);
while(rs.next()){
String col1=rs.getString(1);
String col2=rs.getString(2);
try{
if(i==0){
so.println("<?xml version=\"1.0\" encoding=\"gb2312\" ?>");
so.println("<ufinterface roottag=\"voucher\" billtype=\"gl\" subtype=\"\" replace=\"Y\" receiver=\"1051\" sender=\"1101\" isexchange=\"Y\" filename=\"»á¼Æƾ֤.xml\">");
so.println("<voucher id=\"1234560102\">");
// ×¢Ò⣺ÕâÖÖд·¨ÔÚxmlÎļþÏÔʾʱ»á±¨´í£¬²»ÖªµÀΪʲô£¿ so.println("<custcode>"+col1+"</custcode>");
so.print("<custcode>");
if(col2==null) {//Èç¹û²»Åж϶ÔÏócol2ÊÇ·ñΪnullÖµ£¬ÄÇôÔÚ½øÐбàÂëת»»Ê±¿ÉÄÜ»á³öÏÖNullPointerExceptionÒì³£
so.print(col2);
} else {//ÒòΪǰÃæÒѾ­¶¨ÒåxmlÎļþµÄ±àÂëÏÔʾ·½Ê½ÊÇgb2312£¬


Ïà¹ØÎĵµ£º

.NETÐÞ¸ÄxmlÎļþ

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using i_salesDAL;
using i_s ......

¶ÁдxmlËùÓнڵã¸öÈËС½á ºÍ ¶ÁÈ¡xml½ÚµãµÄÊý¾Ý×ܽá

//´ò¿ªÄ³Îļþ(¼ÙÉèweb.configÔÚ¸ùĿ¼ÖÐ)
     string filename=Server.MapPath("/") + @"WebApplication1\web.config";
     XmlDocument xmldoc= new XmlDocument();
     xmldoc.Load(filename);
     //µÃµ½¶¥²ã½ÚµãÁбí
  ......

JSPÎÄÕÂÄÚÈÝ·ÖÒ³£¨JSP + JDBC£©

±í½á¹¹£º
CREATE TABLE `article` (                              
           `id` int(10) unsigned ......

¹ØÓÚxmlʹÓõĸÐÎò

н¨xmlÎļþµÄÇé¿ö¿ÉÄܲ»¶à£¬µ«¶Ô½Úµã¡¢ÊôÐÔµÄÔöɾ¸Ä²é»áºÜ³£¼û
 XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath("data.xml"));
ÕâÁ½¾äÓ¦¸ÃºÜ³£Óõģ¬¼ÓÔØÒѾ­´æÔÚµÄxmlÎĵµ¡£
XmlNode root;//¸ù½Úµã
root = xmldoc.DocumentElement;//»ñÈ¡¸ù½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ