日期:2014-05-20 浏览次数:21121 次
     protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadXmlFile();
        }
        
    }
    public void LoadXmlFile()
    {      
        string path = Server.MapPath("XML/test.xml");  //这里是你文件路径
        XmlDocument doc = new XmlDocument();
        doc.Load(path);
        XmlNodeList nodeList = doc.SelectNodes("CommonTypes/Types/Type");
        foreach (XmlNode node in nodeList)
        {
            ListItem li = new ListItem(node.InnerText,node.Attributes["ID"].Value);
            DropDownList1.Items.Add(li);  //DropDownList1是ID
        }
    }