【文件属性】:
文件名称:C# XML文件读写操作-源码
文件大小:3KB
文件格式:ZIP
更新时间:2021-01-18 07:51:49
XML, XML读写, XML源码, XML实例
C# XML文件读写操作源码,以及如何调用,注释详解,有任何问题请留言,
以下截取xml文件和部分调用代码段:
* ++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--TestPlugins的信息-->
<!--DataPlugins的信息-->
* ++++++++++++++++++++++++++++
xml xl = new xml();
xl.XMLWriteRootNode("info");
//XmlElement Eml1 = xl.XMLReadNode("",0);
//XmlElement Eml2 = xl.XMLReadNode("DataPlugins", 1);
//XmlElement Eml4 = xl.XMLReadNode("DeviceInfo", 2);
// TestPlugins
XmlElement testPlugins = xl.XMLCreateNode("TestPlugins", null, null);
xl.XMLInsertNode("info", 0, "TestPlugins的信息", testPlugins);
// FixturePlugin
XmlElement fixturePlugin = xl.XMLCreateNode("TestPlugin", null, new Dictionary() { { "Type", "FixturePlugin" } });
xl.XMLInsertNode(testPlugins.LocalName, 1, null, fixturePlugin);
// DUTPlugin
XmlElement DUTPlugin = (XmlElement)fixturePlugin.CloneNode(true);// xl.XMLCreateNode("TestPlugin", null, new Dictionary() { { "Type", "DUTPlugin" } });
DUTPlugin.SetAttribute("Type", "DUTPlugin");
xl.XMLInsertNode(testPlugins.LocalName, 1, null, DUTPlugin);
// Agilent34461APlugin
XmlElement Agilent34461APlugin = xl.XMLCreateNode("TestPlugin", null, new Dictionary() { { "Type", "Agilent34461APlugin" } });
xl.XMLInsertNode(testPlugins.LocalName, 1, null, Agilent34461APlugin);
// ==================================
// DataPlugins
XmlElement dataPlugins = xl.XMLCreateNode("DataPlugins", null, null);
xl.XMLInsertNode("info", 0, "DataPlugins的信息", dataPlugins);
// CSVLogPlugin
XmlElement csvlogPlugin = xl.XMLCreateNode("DataPlugin", null, new Dictionary() { { "Type", "CSVLogPlugin" } });
xl.XMLInsertNode(dataPlugins.LocalName, 1, null, csvlogPlugin);
XmlElement uartlogPlugin = (XmlElement)csvlogPlugin.CloneNode(true);
uartlogPlugin.SetAttribute("Type", "UartLogPlugin");
xl.XMLInsertNode(dataPlugins.LocalName, 1, null, uartlogPlugin);
XmlElement testlogPlugin = (XmlElement)csvlogPlugin.CloneNode(true);
testlogPlugin.SetAttribute("Type", "TestLogPlugin");
xl.XMLInsertNode(dataPlugins.LocalName, 1, null, testlogPlugin);
}
【文件预览】:
XML文件读写源码
----xml.cs(15KB)