国产精品亚洲综合一区在线观看_国产性猛交╳xxx乱大交_中文字幕精品一区二区精品_国产午夜精品一区二区三区不卡_国产亚洲精品久久久久久青梅 _精品国产午夜肉伦伦影院_国产欧美va欧美va香蕉在线_99久久婷婷国产综合精品_国产精品白浆一区二小说

綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門排行|軟件分類|軟件專題|廠商大全

綠色資源網(wǎng)

技術(shù)教程
您的位置:首頁網(wǎng)絡(luò)編程Xml編程 → 讀寫xml文件的2個小函數(shù)

讀寫xml文件的2個小函數(shù)

我要評論 2010/02/07 12:56:10 來源:綠色資源網(wǎng) 編輯:佚名 [ ] 評論:0 點擊:348次

#region 讀寫xml文件的2個小函數(shù),2005 4 2 by hyc

  public void SetXmlFileValue(string xmlPath,string AppKey,string AppValue)//寫xmlPath是文件路徑+文件名,AppKey是 Key Name,AppValue是Value
  {
   XmlDocument xDoc = new XmlDocument();
   xDoc.Load(xmlPath);
   XmlNode xNode;
   XmlElement xElem1;
   XmlElement xElem2;

   xNode =  xDoc.SelectSingleNode("//appSettings");

   xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
   if ( xElem1 != null )
   {
    xElem1.SetAttribute("value",AppValue);
   }
   else
   {
    xElem2 = xDoc.CreateElement("add");
    xElem2.SetAttribute("key",AppKey);
    xElem2.SetAttribute("value",AppValue);
    xNode.AppendChild(xElem2);
   }
   xDoc.Save(xmlPath);
  }


  public void GetXmlFileValue(string xmlPath,string AppKey,ref string AppValue)//讀xmlPath是文件路徑+文件名,AppKey是 Key Name,AppValue是Value
  {
   XmlDocument xDoc = new XmlDocument();
   xDoc.Load(xmlPath);
   XmlNode xNode;
   XmlElement xElem1;

   xNode =  xDoc.SelectSingleNode("//appSettings");

   xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
   if ( xElem1 != null )
   {
    AppValue=xElem1.GetAttribute ("value");
   }
   else
   {
//    MessageBox.Show ("There is not any information!");
   }

  }

  #endregion

關(guān)鍵詞:xml

閱讀本文后您有什么感想? 已有 人給出評價!

  • 1 歡迎喜歡
  • 1 白癡
  • 1 拜托
  • 1 哇
  • 1 加油
  • 1 鄙視

<source id="kxcwz"></source>
<bdo id="kxcwz"><span id="kxcwz"><del id="kxcwz"></del></span></bdo>
    1. <pre id="kxcwz"></pre>