Ejemplo n.º 1
0
        public static void GetURL_lst(List <URL_list> URL_List_)
        {
            XmlDocument       xmlDoc   = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;//忽略文档里面的注释
            XmlReader reader = XmlReader.Create(@"..\..\XMLFile1.xml", settings);

            xmlDoc.Load(reader);
            reader.Close();
            // 得到根节点bookstore
            XmlNode xn = xmlDoc.SelectSingleNode("bookstore");
            // 得到根节点的所有子节点
            XmlNodeList xnl = xn.ChildNodes;

            foreach (XmlNode xn1 in xnl)
            {
                #region MyRegion
                URL_list uls = new URL_list();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;
                // 得到Type和ISBN两个属性的属性值
                uls.ID   = xe.GetAttribute("ID").ToString();
                uls.Name = xe.GetAttribute("Type").ToString();
                // 得到Book节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                uls.Href = xnl0.Item(0).InnerText;
                URL_List_.Add(uls);
                #endregion
            }


            xmlDoc.Clone();
        }
Ejemplo n.º 2
0
 private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         object obj = (object)e.AddedItems;
         textBox.Text = ((newWORD.URL_list)((object[])obj)[0]).Href;
         url_         = ((newWORD.URL_list)((object[])obj)[0]);
     }
     catch (Exception)
     {
     }
 }