?
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
Medium Priority
?
522 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
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

 

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 900 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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