c# - How to display a large XML file (>21MB) in a tree view quickly -


i need display large xml file (>21mb) in tree view control in c# windows form application. have written code working small xml files when trying open big xml file (>1 mb), taking of time. can suggest how can optimise , suggest me changes or alternatives achieve this.

below code snippet:

private void createtreeviewfromatxml(string strsrcfilename)         {             xmldatadocument xmldoc = new xmldatadocument();             xmlnode xmlnode ;             filestream fs = new filestream(strsrcfilename, filemode.open, fileaccess.read);             xmldoc.load(fs);             xmlnode = xmldoc.childnodes[1];             xmltreeview.nodes.clear();             xmltreeview.nodes.add(new treenode(xmldoc.documentelement.name));             treenode tnode ;             tnode = xmltreeview.nodes[0];             addnode(xmlnode, tnode);         }       private void addnode(xmlnode inxmlnode, treenode intreenode)     {         //xmlnode xnode ;         treenode tnode ;         xmlnodelist nodelist ;         int = 0;         if (inxmlnode.haschildnodes)         {             nodelist = inxmlnode.childnodes;              foreach (xmlnode xnode in inxmlnode.childnodes)             {                 tnode = new treenode(xnode.name);                 intreenode.nodes.add(tnode);                 addnode(xnode, tnode);             }         }         else         {             intreenode.text = inxmlnode.innertext.tostring();         }     } 

i wrap code this:

xmltreeview.beginupdate(); try {     createtreeviewfromatxml(strsrcfilename); } catch (exception e) {     //handle error } {     xmltreeview.endupdate(); } 

if you're not in update block it's repainting gui on every node add , that's expensive. have recursion in addnode if xml isn't nested shouldn't issue.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -