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);
}
1