using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;namespace COMMON
{
public class XmlHelperClass
{
public void Read()
{
Dictionary<string, string> m_FontList = new Dictionary<string, string>();
try
{
XmlDocument doc = new XmlDocument();// 获得配置文件的全路径
string strFileName = "Font.xml";
doc.Load(strFileName);
XmlNode node = doc.GetElementById("font");
XmlNodeList nodes = node.ChildNodes;
for (int i = 0; i < nodes.Count; i++)
{
if (nodes[i].NodeType == XmlNodeType.Element)
{
m_FontList[nodes[i].Name] = nodes[i].InnerText;
}
}
}
catch (Exception e)
{
throw e;
}
}public void Write(string tagName, string value)
{
XmlDocument doc = new XmlDocument();//获得配置文件的全路径
string strFileName = @"C:\Program Files\IIS Express/Font.xml";
doc.Load(strFileName);
XmlNode node = doc.GetElementById("font");
XmlNodeList nodes = node.ChildNodes;
for (int i = 0; i < nodes.Count; i++)
{
if (nodes[i].Name.Equals(tagName))
{
nodes[i].InnerText = value;
}
}
try
{
//保存上面的修改
doc.Save(strFileName);}
catch (Exception e)
{
throw e;
}
}
}
}