vs2005 xml
下一个怎么做usingSystem.Xml;usingSystem.IO;Page_Loadif(!IsPostBack){ViewState["number"]=0;s...
下一个怎么做
using System.Xml;
using System.IO;
Page_Load
if (!IsPostBack)
{
ViewState["number"] = 0;
string stuName = "", email = "", headImage = "";
//先把XML文件内容读取
XmlReaderSettings setting = new XmlReaderSettings();
setting.IgnoreComments = true;
setting.IgnoreWhitespace = true;
string addressFile = Server.MapPath("address.xml");
XmlReader reader = XmlReader.Create(addressFile, setting);
while (reader.Read())
{
if (reader.LocalName == "stuName")
stuName = reader.ReadString();
if (reader.LocalName == "email")
email = reader.ReadString();
if (reader.LocalName == "headImage")
{
headImage = reader.ReadString();
break;
}
} 展开
using System.Xml;
using System.IO;
Page_Load
if (!IsPostBack)
{
ViewState["number"] = 0;
string stuName = "", email = "", headImage = "";
//先把XML文件内容读取
XmlReaderSettings setting = new XmlReaderSettings();
setting.IgnoreComments = true;
setting.IgnoreWhitespace = true;
string addressFile = Server.MapPath("address.xml");
XmlReader reader = XmlReader.Create(addressFile, setting);
while (reader.Read())
{
if (reader.LocalName == "stuName")
stuName = reader.ReadString();
if (reader.LocalName == "email")
email = reader.ReadString();
if (reader.LocalName == "headImage")
{
headImage = reader.ReadString();
break;
}
} 展开
2个回答
展开全部
for (int m = 0; m < 5; m++)
reader.Read();
if (reader.LocalName != "student")
Button1.Enabled=false;
Response.Write(reader.LocalName);
//把读取的内容放到LABEL和IMAGE里
Label1.Text = stuName;
Label2.Text = email;
Image1.ImageUrl = "headimages\\" + headImage;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["number"] = Convert.ToInt32(ViewState["number"]) + 1;
string stuName="",email="",headImage="";
//先把XML文件内容读取
XmlReaderSettings setting = new XmlReaderSettings();
setting.IgnoreComments = true;
setting.IgnoreWhitespace = true;
string addressFile = Server.MapPath("address.xml");
reader.Read();
if (reader.LocalName != "student")
Button1.Enabled=false;
Response.Write(reader.LocalName);
//把读取的内容放到LABEL和IMAGE里
Label1.Text = stuName;
Label2.Text = email;
Image1.ImageUrl = "headimages\\" + headImage;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["number"] = Convert.ToInt32(ViewState["number"]) + 1;
string stuName="",email="",headImage="";
//先把XML文件内容读取
XmlReaderSettings setting = new XmlReaderSettings();
setting.IgnoreComments = true;
setting.IgnoreWhitespace = true;
string addressFile = Server.MapPath("address.xml");
展开全部
XmlReader reader = XmlReader.Create(addressFile, setting);
for (int i = 0; i < 3; i++)
reader.Read();
for (int i = 0; i < Convert.ToInt32(ViewState["number"]); i++)
for (int j = 0; j < 23;j++ )
reader.Read();
while(reader.Read())
{
if(reader.LocalName=="stuName")
stuName=reader.ReadString();
if (reader.LocalName == "email")
email=reader.ReadString();
if (reader.LocalName == "headImage")
{
headImage = reader.ReadString();
break;
}
}
for (int m = 0; m < 5; m++)
reader.Read();
if (reader.LocalName != "student")
Button1.Enabled = false;
Response.Write(reader.LocalName);
//把读取的内容放到LABEL和IMAGE里
Label1.Text = stuName;
Label2.Text = email;
Image1.ImageUrl = "headimages\\" + headImage;
}
for (int i = 0; i < 3; i++)
reader.Read();
for (int i = 0; i < Convert.ToInt32(ViewState["number"]); i++)
for (int j = 0; j < 23;j++ )
reader.Read();
while(reader.Read())
{
if(reader.LocalName=="stuName")
stuName=reader.ReadString();
if (reader.LocalName == "email")
email=reader.ReadString();
if (reader.LocalName == "headImage")
{
headImage = reader.ReadString();
break;
}
}
for (int m = 0; m < 5; m++)
reader.Read();
if (reader.LocalName != "student")
Button1.Enabled = false;
Response.Write(reader.LocalName);
//把读取的内容放到LABEL和IMAGE里
Label1.Text = stuName;
Label2.Text = email;
Image1.ImageUrl = "headimages\\" + headImage;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询