public struct MenuClass ////定义数据结构
{
public string id;
public string name;
public string name_en;
public string url;
public string pic;
public string sel;
public string banner;
}
public string menustring_top;
protected void Page_Load(object sender, EventArgs e)
{
/////////XML横向导航栏/////////////////////////////////////////////////////////////////
int MenuCount;
//////////读取XML
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("datafiles/menu.xml"));
MenuCount = ds.Tables["m1"].Rows.Count;
MenuClass[] MC = new MenuClass[MenuCount]; //定义自定义类型的数组
for (int i = 0; i < MenuCount; i++)
{
MC[i].id = ds.Tables["m1"].Rows[i]["id"].ToString();
MC[i].name = ds.Tables["m1"].Rows[i]["name"].ToString();
MC[i].name_en = ds.Tables["m1"].Rows[i]["name_en"].ToString();
MC[i].url = ds.Tables["m1"].Rows[i]["url"].ToString();
MC[i].pic = ds.Tables["m1"].Rows[i]["pic"].ToString();
MC[i].sel = ds.Tables["m1"].Rows[i]["sel"].ToString();
MC[i].banner = ds.Tables["m1"].Rows[i]["banner"].ToString();
//Response.Write(ds.Tables["m1"].Rows[i]["name"].ToString());
}
string cur="0";
if (Request.QueryString["sel"] == null) { cur = "0"; } else { cur=Request.QueryString["sel"]; }
for (int i = 0; i < MenuCount; i++)
{
string tmp = "";
if (i.ToString() == cur) { tmp = "current"; }
menustring_top += "
" + MC[i].name.ToString() + "";
}
}