posts - 5,  comments - 5,  trackbacks - 0
          xml

          下面是通過讀取xml文件中的內容并顯示在textbox的例子:


          using System;
          using System.Data;
          using System.Configuration;
          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 System.Xml;
          using System.Xml.XPath;

          public partial class _Default : System.Web.UI.Page
          {
          ??? public string[] x = new string[4];
          ??? protected void Page_Load(object sender, EventArgs e)
          ??? {

          ??????? XmlDocument xmlDoc = new XmlDocument();
          ??????? xmlDoc.Load(Server.MapPath("table.xml"));//你的xml文件
          ??????? XmlNodeList xmlList = xmlDoc.SelectSingleNode("MapSheet").ChildNodes;
          ??????? foreach (XmlNode xmlNo in xmlList)
          ??????? {
          ??????????? //XmlNodeList xe = (XmlNodeList)xmlNo;
          ??????????? XmlElement xe = (XmlElement)xmlNo;
          ??????????? {
          ??????????????? if (xe.Name == "TableName")
          ??????????????? {
          ??????????????????? y[0] = xe.InnerText;
          ??????????????? }

          ??????????????? if (xe.Name == "DataSource")
          ??????????????? {
          ??????????????????? y[1] = xe.InnerText;
          ??????????????? }

          ??????????????? if (xe.Name == "UserName")
          ??????????????? {
          ??????????????????? y[2] = xe.InnerText;
          ??????????????? }

          ??????????????? if (xe.Name == "Password")
          ??????????????? {
          ??????????????????? y[3] = xe.InnerText;
          ??????????????? }
          ??????????? }
          ??????? }
          ??????? TextBox1.Text=y[0];
          ??????? TextBox2.Text = y[1];
          ??????? TextBox3.Text = y[2];
          ??????? TextBox4.Text = y[3];
          ??? }


          }該程序已經過測試,沒有問題。

          posted on 2006-11-12 15:21 曾科 閱讀(143) 評論(0)  編輯  收藏 所屬分類: C#
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(3)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          .net

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 南汇区| 东台市| 博野县| 如皋市| 高密市| 青浦区| 绥宁县| 独山县| 普兰店市| 甘洛县| 毕节市| 临洮县| 乌拉特中旗| 红安县| 沈丘县| 当涂县| 成安县| 云龙县| 古田县| 鄂托克旗| 克东县| 拉萨市| 无棣县| 西城区| 常宁市| 突泉县| 盐池县| 商城县| 特克斯县| 平舆县| 万山特区| 木兰县| 铜陵市| 靖安县| 永福县| 威远县| 小金县| 隆安县| 靖西县| 平远县| 上犹县|