c# - How I get the Parametervalue of a xml for the treeview`? -
hi have xml , want show in treeview in c#
it works treeview don't show me want see.
i try explain problem:
here xml:
<?xml version="1.0" encoding="utf-8"?> <lm-x stat_version="3.32"> <license_path type="network" host="6200@lwserv005" server_version="4.4.4" uptime="53 day(s) 21 hour(s) 10 min(s) 50 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="lwserv171" 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"/> ... </license_path> </lm-x>
i want in treeview structure how this: features
globalzoneeu hwaifpbs hwawpf ...
here c# code:
private void btnshowlicstate_click(object sender, eventargs e) { string command = "\"c:\\lmxendutil.exe\" -licstatxml -host lwserv005 -port 6200"; string output = executecommand(command); string final_output = output.substring(90, output.length-90); xdocument doc = xdocument.parse(final_output); buildtree(treelic, doc); 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; } private void buildtree(treeview treeview, xdocument doc) { treenode treenode = new treenode(doc.root.name.localname); treeview.nodes.add(treenode); buildnodes(treenode, doc.root); } private void buildnodes(treenode treenode, xelement element) { foreach (xnode child in element.nodes()) { switch (child.nodetype) { case xmlnodetype.element: xelement childelement = child xelement; treenode childtreenode = new treenode(childelement.name.localname); treenode.nodes.add(childtreenode); buildnodes(childtreenode, childelement); break; case xmlnodetype.text: xtext childtext = child xtext; treenode.nodes.add(new treenode(childtext.value)); break; } } }
how can names of nodes example--->
<feature name="globalzoneeu" version="12.0" vendor="altair" ...>
i want name ...
not entirely sure want, looking
(string)childelement.attributes("name")
instead of
childelement.name.localname
?
Comments
Post a Comment