嗨,我如何使用与树视图的 xml 文件具有相同结构的字符串。例如,这里是字符串内容的一部分..
<?xml version="1.0" encoding="UTF-8"?>
<LM-X STAT_VERSION="3.32">
<LICENSE_PATH TYPE="NETWORK" HOST="6200@serv005" SERVER_VERSION="4.4.4" UPTIME="53 day(s) 23 hour(s) 0 min(s) 3 sec(s)">
<FEATURE NAME="GlobalZoneEU" VERSION="12.0" VENDOR="ALTAIR" START="2013-03-26" END="2014-03-31" USED_LICENSES="111720" TOTAL_LICENSES="147000" SHARE="CUSTOM ,VIRTUAL">
<USER NAME="SYSTEM" HOST="SERV171" IP="172.16.11.115" USED_LICENSES="2000" LOGIN_TIME="2013-04-17 12:42" CHECKOUT_TIME="2013-04-17 12:42" SHARE_CUSTOM="hweuser:172.16.11.115"/>
>
....
这只是一个字符串。
我想将此字符串用作 xml 文件的方式...我可以将此字符串转换为(虚拟)xml 并用 FEATURE 或 USER 的节点填充我的树视图吗?
我的 C# 代码:
private void btnShowLicstate_Click(object sender, EventArgs e)
{
string command = "\"C:\\lmxendutil.exe\" -licstatxml -host serv005 -port 6200";
string output = ExecuteCommand(command);
string final_output = output.Substring(90, output.Length-90);
// here i want to parse the string in a xml format string xD and load this in the treeview
txtOutput.Text = final_output;
}
static string ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
string output = process.StandardOutput.ReadToEnd();
exitCode = process.ExitCode;
process.Close();
return output;
}