Software Support > PowerMAME
Question to PowerMAME32 users
Silver:
vb6 - I found a great XML parser as part of the MSXML package. The default "DOM Document" approach was horrible - took ages to run and consumed 400megs RAM to read variables from the mame xml output. However, there is also a nifty SAX parser in there. Its a one pass approach - it flies through the xml file and reads any data you flag into variables or whatever in seconds or less, for the whole 30meg file.
SirPoonga:
yep, sax is the way togo. DOM builds the entire tree in memory, hence why it took up so much. SAX deals with the file as you read it. Each has it purpose, but for this SAX is what you need.
Howard_Casto:
I haven't gotten enough time to really mess with sax yet, but considering I'm currently rebuilding dk's core in a few minor areas it might be worth a look. You guys wouldn't know if there is a way to treat an xml hierarchy like a database would you? Mind you I can load my text files into a database, but that requires dependencies and I like to keep my apps as lite as possible these days.
I'm looking for a faster way to implement my filtration system barring the obvious solution (an access database). I want something I can do totally in memory but has built in searching features that are actually fast when filtering out the 5,000+ entry masterlist the average dk user would have.
Silver:
I'm no expert programmer, generally learning as I go...
The DOM approach lets you essentially treat the XML as a database, (it loads the entire tree to memory, and you can search for any value or node) but is essentially useless for any reasonably sized XML file. (Don't even think about it for mame).
What I did is do a single pass of the XML file using the SAX parser, but I flagged up all the info I was interested in - romname, full game name, romof, cloneof, and every joystick and button, - for every game. All of this info is passed into simple arrays in memory during the parse. Everything else in the xml is ignored. The entire process takes well under 2 seconds for me. This gives me arrays so that if rom(10) is 1942, then romname(10), full game name(10), romof(10), cloneof(10),joystick(10)..... gives all the info associated with 1942.
I then go through the users actual roms on disk and pull the info from the arrays as needed. So if I find 1942.zip in the rom folder, I'll search the rom() array for '1942' to find its position in the array - get a return of '10' - and I have instant access to all the info I need for 1942. (You can build a Hash table of the rom() for searching - makes it enormously quick to search).
This is a bit simplistic, and its not that far removed from txt scanning the xml line by line and pulling all the info you need, but the SAX parser (from MSXML I used - yes a dependancy - but I think there are lots of other SAX parsers out there) is basically doing the same thing and returning data for nodes you specify in advance....
(In my program I SAX parse mame.xml and then controlsdat.xml to pull all the data into memory arrays, then search controlsdat to get accurate data, then search mame.xml if controlsdat has no info - remember to check for clones in controlsDat of course... ;) )
Howard_Casto:
Well right now I take listinfo data, convert it into easy to read delimeted text files and load the whole thing into a 3d array in memory. It's essentially what you are describing, it just makes for very slow filtering as you have to search every game entry programatically instead of calling a function and have windows do it "automagically".
I did find an article the other day on how to use .net classes/dlls/ect in vb6. This is very cool as I now have access to the .net xml goodies. It'll take some research to get it working properly though.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version