| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 616 人关注过本帖
标题:asp.ner 本想让XML内容在表格中循环输出,但做不到。 求Label.Text循环输出 ...
只看楼主 加入收藏
dsa403839449
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-6-13
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
asp.ner 本想让XML内容在表格中循环输出,但做不到。 求Label.Text循环输出的本法或自动生成动态表格的办法
程序代码:
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[7];
    protected void Page_Load(object sender, EventArgs e)
    {
       
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath("x1.xml"));//你的xml文件
        XmlNodeList xmlList = xmlDoc.SelectSingleNode("bookshelf").ChildNodes;
        for (int i = 0; i < xmlList.Count;i++ )
        {
            foreach (XmlNode xmlNo in xmlList.Item(i))
            {
               
                XmlElement xe = (XmlElement)xmlNo;
                {
                        if (xe.Name == "name")
                        {
                            x[0] = xe.InnerText;
                        }

                        if (xe.Name == "author")
                        {
                            x[1] = xe.InnerText;
                        }

                        if (xe.Name == "company")
                        {
                            x[2] = xe.InnerText;
                        }

                        if (xe.Name == "type")
                        {
                            x[3] = xe.InnerText;
                        }
                        if (xe.Name == "intro")
                        {
                            x[4] = xe.InnerText;
                        }
                        if (xe.Name == "danjia")
                        {
                            x[5] = xe.InnerText;
                        }
               }
            }
        Response.Write(x[0]+"<br>");
        Response.Write(x[1] + "<br>");
        Response.Write(x[2] + "<br>");
        Response.Write(x[3] + "<br>");
        Response.Write(x[4] + "<br>");
        Response.Write(x[5] + "<br>");  

        //Label1.Text = x[0];
        //Label2.Text = x[1];
        //Label3.Text = x[2];
        //Label4.Text = x[3];
        //Label5.Text = x[4];
        //Label6.Text = x[5];

            }
    }
}[local]1[/local]

本想让XML内容在表格中循环输出,但做不到。  求Label.Text循环输出的本法或自动生成动态表格的办法


}E8XYJEJ[{}$KG8GFEYQW1U.jpg (21.31 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 表格 动态 
2012-06-13 15:03
qmoneyg
Rank: 2
来 自:湖北武汉
等 级:论坛游民
帖 子:4
专家分:30
注 册:2012-6-13
收藏
得分:20 
学习一下!
2012-06-13 21:35
快速回复:asp.ner 本想让XML内容在表格中循环输出,但做不到。 求Label.Text循 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015803 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved