XML文件内容如下:
<?xml version="1.0" encoding="GB2312"?>
<languagePack>
<base>
<alt_img_news>图片新闻</alt_img_news>
<alt_headline>头条新闻</alt_headline>
</base><admin_login.aspx>
<login_timeout>验证码已过期,请重登陆</login_timeout>
<login_wrong_code>验证码错误,请重登陆</login_wrong_code>
</admin_login.aspx>
</languagePack>现在就是想用DataSet.ReadXml一次读入,再取比如admin_login.aspx/login_timeout里面的值,下次再需要取其它值的时候不用再次读入了,有一个DataSet静态变量,具体如何写?

解决方案 »

  1.   


      看看这种效果是不是你要的?
      先把XML文件读到XML 然后不同的页面名称 和 字段从中取出来  DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("~/XMLFile.xml"));
            Response.Write(ds.Tables["admin_login.aspx"].Rows[0][0].ToString());
            Response.Write("<br>");
            Response.Write(ds.Tables["admin_login.aspx"].Rows[0]["login_timeout"].ToString());
            Response.Write("<br>");
            Response.Write(ds.Tables["admin_login.aspx"].Rows[0]["login_wrong_code"].ToString());
            Response.Write("<br>");
            Response.Write(ds.Tables["admin_login.aspx"].Rows[0][1].ToString());
            Response.Write("<br>");
      

  2.   

    protected void WriteToXML(XmlNode theNode, ArrayList arrList)
            {
                foreach(string thename in arrList)
                {
                xmlElem = xmlDoc.CreateElement("Name");
                xmlElem.InnerText = encryer.Encrypto(thename);
                theNode.AppendChild(xmlElem);
                }            
            }