• activation program离线激活工具汉化版
  • vm16虚拟机中文破解版附激活密钥(vmwareworkstationpro17)
  • 小修 Win11 LTSC2024极限精简版
所在位置: 首页 > 教程资讯 > 网络编程

XML处理_XML处理函数示例

时间:2026-02-27 12:14:44

标签: AppKey| XML处理函数 读写XML XML文件 XML

#region 读写xml文件的2个小函数,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

Highcharts(图表API库)

Highcharts(图表API库)

2分

下载
图吧工具箱电脑版安装包

图吧工具箱电脑版安装包

系统优化 | 226.29M

相关资讯

热门攻略