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
485 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
  • 4
  • 3
7 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
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
Comment Utility
have a question: how many items has your 12Mb xml?
sounds like it is too much information for a menu.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:xyntekinc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
using WPF treeview works the best, and lazy-load was not needed.  the solution would have worked but was overly complex.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now