Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
XML with wxPerlby SuperCruncher (Pilgrim) |
on Mar 21, 2002 at 17:55 UTC ( [id://153366]=perlquestion: print w/replies, xml ) | Need Help?? |
SuperCruncher has asked for the wisdom of the Perl Monks concerning the following question:
As mentioned in one of my recent nodes, WxPerl woes -- putting a Tree into a ScrolledWindow, I am writing my final year project using wxPerl. I have been struggling, but thanks to help from Jouke and the wxPerl mailing list, I've been making progress. Anyway, the program is an MP3 organiser--it stores information on various "volumes" (parts of a user's collection - a volume can be either a drive on fixed media or removable media, and possibly remote locations). These volumes are stored as XML files, using a DTD that I have created. A sample document is presented below:
A few points: directories can contain unlimited directory and file tags. The artist, title etc. tags can exist only inside 'file' tags. The final application is intended to look something like this screenshot, i.e. a tree with an entry for each volume and each of its subdirectories (recursively). Note in the screenshot that 'Test' and 'Test' are 2 different volumes. When the user clicks on a particular directory, the contents of that directory (whether they are files or more directories) should be displayed in the right-hand pane. I have implemented this in a rather 'hacked' and far from perfect fashion. In the constructor for my frame, I call a function in package main which sets global variables (using our) in main to store a reference to the tree object and to the current "ID" (the ID is used to denote where an entry into the tree should be inserted), i.e. I can create the actual tree (with volumes and directories) fine. I used a 'stack' approach, keeping the ID of the next entry to be inserted at the top of the stack, and popping it off whenever an end tag for 'directory' is encountered. (The stack is then cleared before starting another volume.) The problem is storing data on the files and linking this to what volume they are on, and what the 'properties' of the volume are. The hack I have used is as follows:
Also, if you've read this far, thanks--I know this is a long posting, but I felt it was important to explain the situation as clearly as possible and include all relevant information.
Back to
Seekers of Perl Wisdom
|
|