Solved

is there a way to display a large xml file of bookmark/link format in a menu structure in a C# windows application?

Posted on 2010-09-20
7
508 Views
Last Modified: 2013-12-16
the issue is the following:  i'm trying to display a catalog of bookmarks maintained in an XML file.  on application load, the xml file is read and parsed into a mirrored structure of ToolStripMenuItems (folders and links).  a recursive function is used to traverse the file, as is customary for navigating tree structures, and the file loads fine when it is small.  However, both the time required to execute the recursion and the memory required to hold all of the objects becomes absurdly large (12MB xml file = 10-15seconds to load/traverse = 750MB-1.5GB of memory depending on OS and system RAM).  In .net / web world, I would be able to set the datasource for the menu structure to the xml file and let it manage/run that way, but that functionality does not seem to exist in the client-side windows app.  
does anyone have any insight into a way to handle a large bookmark file or bind a large xml-based menu structure in a windows C# application?
0
Comment
Question by:xyntekinc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 33721969
Well, this is not a trivial task, but the answer is: lazy binding.
You should not load all the xml into memory. What you need is some kind of in-memory indexing.

I would assume you will show the information in a tree-like fashion, so you can load just the information which is visible.
This way: You don't spend time loading ALL the xml into memory in-advance, but few milliseconds to load what is visible every time you open a tree leaf.

Does it sound like a good start?
0
 

Author Comment

by:xyntekinc
ID: 33722329
it does, and that was actually a tentative plan, but i was not sure exactly how to go about tracking the up-and-down levels and building at run-time.  also,  i was really hoping for a way to "bind" the xml to a menu instead of creating new (bloated) menuitem objects for every single link.  should i pursue the lazy binding / dynamic-loading plan, 2 questions: 1) what type of performance hit can i expect and 2) what is the best/fastest way to maintain, index, and load the xml doc?  i suppose i could store the doc in memory so the 12MB disk-read is not necessary on every click.  the potential issue i saw was handling the mouse-over events of the folder nodes without disrupting the view/UI of the menu structure.  i'm not looking for code, just suggestions or best practices.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 33722424
have a question: how many items has your 12Mb xml?
sounds like it is too much information for a menu.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:xyntekinc
ID: 33727482
i'm not sure exactly how many, but i'd say somewhere in the hundreds... 200ish probably.  I agree that it is much more than a menu is designed to hold (especially given the amount of memory each menuitem requires), but what other ways are there to maintain that tree-like menu structure in a GUI?  the contents of the bookmarks/link menus are the bread-and-butter of the application.  it worked in previous versions of the application built in C++ (.net 2005 i believe), as the objects were substantially smaller in memory.
unless there is another similar structure or object that will allow an xml doc to bind to it, i think the lazy/dynamic binding is a viable alternative if the event-handling can be handled in the background without drastically degrading the user-experience.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 300 total points
ID: 33731616
I would suggest to use a regular treeview object. You can style it to look like a menu (gray background, highlighted in blue, etc)
there are many examples of "lazy load" for treeviews. Here is some article about WPF treeview, but concept can be applied to winforms as well:
http://www.codeproject.com/KB/WPF/TuningTheTreeView_1.aspx
0
 

Author Comment

by:xyntekinc
ID: 33843051
i have yet to give the lazy-load a try.  that seems like the best alternative, short of integrating a web-component into the application and attempting to use the treeview menu structure with datasource that way.
0
 

Author Closing Comment

by:xyntekinc
ID: 34066257
using WPF treeview works the best, and lazy-load was not needed.  the solution would have worked but was overly complex.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question