问题描述
XML文件<?xmlversion="1.0"encoding="UTF-8"?><?xml-stylesheettype="text/xsl"href="view2.xsl"?><项目工作日志><项目名称></项目名称><项目编号></项目编号><日志内容></日志内容><作业人员></作业人员><工作日期></工作日期><填报日期></填报日期></项目工作日志>XSLT文件<?xmlversion="1.0"encoding="UTF-8"?><!--DWXMLSource="项目.xml"--><xsl:stylesheetversion="1.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-02-23T06:56:26"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:msxsl="urn:schemas-microsoft-com:xslt"xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"xmlns:x="urn:schemas-microsoft-com:office:excel"xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension"xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"xmlns:xdSolution="http://schemas.microsoft.com/office/infopath/2003/xslt/solution"xmlns:xdFormatting="http://schemas.microsoft.com/office/infopath/2003/xslt/formatting"xmlns:xdImage="http://schemas.microsoft.com/office/infopath/2003/xslt/xImage"xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util"xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math"xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date"xmlns:sig="http://www.w3.org/2000/09/xmldsig#"xmlns:xdSignatureProperties="http://schemas.microsoft.com/office/infopath/2003/SignatureProperties"xmlns:ipApp="http://schemas.microsoft.com/office/infopath/2006/XPathExtension/ipApp"xmlns:xdEnvironment="http://schemas.microsoft.com/office/infopath/2006/xslt/environment"xmlns:xdUser="http://schemas.microsoft.com/office/infopath/2006/xslt/User"><xsl:outputmethod="html"indent="no"/><xsl:templatematch="项目工作日志"><html><head></head><bodystyle="COLOR:#000000;BACKGROUND-COLOR:#ffffff"><div><div> </div><div><strong><fontsize="5">项目工作日志</font></strong></div><div><hr/></div></div><div>项目名称:<xsl:variablename="id"select="项目名称"/><inputtype="text"class="xdTextBox"name="CTRL1"id="CTRL1"style="WIDTH:243px"value="{项目名称}"/></div><div>项目编号:<inputclass="xdTextBox"hideFocus="1"title=""xd:xctname="PlainText"xd:CtrlId="CTRL2"xd:binding="项目编号"tabIndex="0"style="WIDTH:100px"value="{项目编号}"/></div><div>日志内容:<inputclass="xdTextBox"hideFocus="1"title=""xd:xctname="PlainText"xd:CtrlId="CTRL3"xd:binding="日志内容"tabIndex="0"style="WIDTH:100%;HEIGHT:165px"value="{日志内容}"/></div><div>作业人员:<inputclass="xdTextBox"hideFocus="1"title=""xd:xctname="PlainText"xd:CtrlId="CTRL4"xd:binding="作业人员"tabIndex="0"style="WIDTH:114px"value="{作业人员}"/></div><div>工作日期:<inputid="d11"type="text"onClick="WdatePicker()"class="xdDTPicker"title=""style="WIDTH:130px"noWrap="1"xd:binding="工作日期"value="{工作日期}"/></div><div>填报日期:<inputid="dll"type="text"onclick="WdatePicker()"class="xdDTPicker"title=""style="WIDTH:124px"noWrap="1"xd:binding="填报日期"value="{填报日期}"/></div></body></html></xsl:template></xsl:stylesheet>在VS05里的页面代码usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Xml;usingSystem.IO;usingSystem.Data.SqlClient;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){Xml1.DocumentSource=Server.MapPath("项目.xml");Xml1.TransformSource=Server.MapPath("view2.xsl");}}protectedvoidbtntj_Click(objectsender,EventArgse){SqlConnectionconn=newSqlConnection("Server=localhost;DataBase=xml;IntegratedSecurity=SSPI");conn.Open();stringsql="insertintoXangMuvalues(@xiangmu,@xmbh,@rznr,@zyry,@gzrq,@tbrq)";SqlCommandcmd=newSqlCommand(sql,conn);DataSetds=newDataSet();ds.ReadXml(Server.MapPath("项目.xml"));stringxiangmu=ds.Tables[0].Rows[0]["项目名称"].ToString();stringxmbh=ds.Tables[0].Rows[0]["项目编号"].ToString();stringrznr=ds.Tables[0].Rows[0]["日志内容"].ToString();stringzyry=ds.Tables[0].Rows[0]["作业人员"].ToString();stringgzrq=ds.Tables[0].Rows[0]["工作日期"].ToString();stringtbrq=ds.Tables[0].Rows[0]["填报日期"].ToString();SqlParameterpara=newSqlParameter("@xiangmu",SqlDbType.NVarChar,50);para.Value=xiangmu;cmd.Parameters.Add(para);para=newSqlParameter("@xmbh",SqlDbType.NVarChar,50);para.Value=xmbh;cmd.Parameters.Add(para);para=newSqlParameter("@rznr",SqlDbType.NVarChar,50);para.Value=rznr;cmd.Parameters.Add(para);para=newSqlParameter("@zyry",SqlDbType.NVarChar,50);para.Value=zyry;cmd.Parameters.Add(para);para=newSqlParameter("@gzrq",SqlDbType.NVarChar,50);para.Value=gzrq;cmd.Parameters.Add(para);para=newSqlParameter("@tbrq",SqlDbType.NVarChar,50);para.Value=tbrq;cmd.Parameters.Add(para);cmd.ExecuteNonQuery();Response.Write("插入成功!");conn.Close();}}