昨天是想做一个通用的读与写的东西,可是今天突然发现我要用的没有那么通用性,后来在Vector的帮助下还是完成了,谢谢vector。
using System.IO;
using System.Xml;
这两个头文件是不可能少的,其实系统会提示的,但是你要确保你写的方法名是没有错误的不然你就急吧。
class ConfiguFile
{
string _xmlPath;
public ConfiguFile(string xmlPath)
{
_xmlPath = Path.GetFullPath(xmlPath);
}
public void Write(string value, List<NodeInfo> nodefo, string Fullvalue)
{
//初始化xml
XmlDocument xmlDoc = new XmlDocument();
XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "GB2312", null);
xmlDoc.AppendChild(dec);
//创建一个根节点(一级)
XmlElement root = xmlDoc.CreateElement(value);
xmlDoc.AppendChild(root);
XmlElement LastSet11 = xmlDoc.CreateElement("Edge");
LastSet11.SetAttribute("Name", Fullvalue);
// LastSet11.SetAttribute("Height", nodefo[0].heigh.ToString());
root.AppendChild(LastSet11);
for (int i = 0; i < nodefo.Count(); i++)
{
XmlElement LastSet = xmlDoc.Creat