tianjun,support" />
小田的空间

生活的理想,是为了理想的生活!

---->>Nothing is impossible for a willing heart.

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  83 随笔 :: 17 文章 :: 133 评论 :: 1 引用

下面是通过读取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[] y = 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-10-21 19:33 tianjun 阅读(1116) 评论(5)  编辑 收藏 所属分类: Web Services

评论

#1楼 2006-10-23 09:50 李振波      
怎么上面定义的是x,下面却用y呀。。。
  回复  引用  查看    

#2楼[楼主] 2006-10-23 11:59 千里之外      
@李振波
谢谢楼上提示,太粗心,写错了,改了,哈哈!!!!!!!!!

  回复  引用  查看    

怎么不能用,还要加什么代码吗?
  回复  引用    

xuexi
  回复  引用    

#5楼 2007-08-21 17:51 阿郑[未注册用户]
请问Table.xml的格式是怎么样的?@千里之外

  回复  引用    




发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 535967




相关文章:

相关链接: