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
494 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
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

838 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