使用XmlDocument 读取books.xml中的书名到DropDownList中

it2022-05-21  49

XmlDocument xdoc;          protected void Page_Load(object sender, EventArgs e)        {            if (!IsPostBack)            {                xdoc = new XmlDocument();//声明一个xml文档,xdoc代表一个xml文档                xdoc.Load(Server.MapPath("books.xml"));//把xml文档复制一份给xdoc                XmlNodeList list = xdoc.GetElementsByTagName("name");                foreach (XmlNode node in list)                {                    this.DropDownList1.Items.Add(node.InnerText);                }                Session["doc"] = xdoc;            }            else            {                xdoc = Session["doc"] as XmlDocument;            }        }

转载于:https://www.cnblogs.com/qzc900809/archive/2012/12/20/2826983.html

相关资源:数据结构—成绩单生成器

最新回复(0)