BillKSmith has asked for the wisdom of the Perl Monks concerning the following question:
Several years ago, I wrote a program under windows XP, which fetches scores for the frecell game and computes additional statistics. This program does not work on my 64-bit windows 7 system because Microsoft has moved these scores from the registry to a file.
With a little help from google, I have found that this data is stored in an xml format and appended to a large (approx 72k) block of binary data. Characters are encoded as a 2-byte unicode (ASCII code in the first byte, null in the second) The sample below includes one of the required parameters: <GamesPlayed>451</Games_Played>.
I am able to read the file as a binary file, find and extract the data with a regular expression, and concatenate the digits to form the numeric result.
I would like a cleaner, more flexible approach. Note: I only need 'read' access. There is no requirement to change the scores.
Several XML modules return a hash of the xml data. This would be perfect but I have not found one that can skip over the irrelevant binary data and handle the backward character encoding. I do not know if the block of binary data has a fixed length. For now, I must assume that it does not.
Here is a hex dump of the start of the xml (made with xxd command of vim):
"C:\Users\Bill\AppData\Local\Microsoft Games\FreeCell\FreeCellSettings.xml"
00119c0: b324 2d18 bb60 6f83 47f8 8b61 648b 70e1 .$-..`o.G..ad.p. 00119d0: fdf3 f7ff 070e 990a 8199 f3a1 b500 0000 ................ 00119e0: 0049 454e 44ae 4260 8216 0600 00ff fe3c .IEND.B`.......< 00119f0: 0052 006f 006f 0074 003e 000a 0020 0020 .R.o.o.t.>... . 0011a00: 0020 0020 003c 0053 0074 0061 0074 0073 . . .<.S.t.a.t.s 0011a10: 003e 000a 0020 0020 0020 0020 0020 0020 .>... . . . . . 0011a20: 0020 0020 003c 0056 0065 0072 0073 0069 . . .<.V.e.r.s.i 0011a30: 006f 006e 003e 0030 003c 002f 0056 0065 .o.n.>.0.<./.V.e 0011a40: 0072 0073 0069 006f 006e 003e 000a 0020 .r.s.i.o.n.>... 0011a50: 0020 0020 0020 0020 0020 0020 0020 003c . . . . . . . .< 0011a60: 0047 0061 006d 0065 0073 0050 006c 0061 .G.a.m.e.s.P.l.a 0011a70: 0079 0065 0064 003e 0034 0035 0031 003c .y.e.d.>.4.5.1.< 0011a80: 002f 0047 0061 006d 0065 0073 0050 006c ./.G.a.m.e.s.P.l 0011a90: 0061 0079 0065 0064 003e 000a 0020 0020 .a.y.e.d.>... .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extract data from non-standard .xml file
by choroba (Cardinal) on Jan 20, 2015 at 13:32 UTC | |
by BillKSmith (Monsignor) on Jan 21, 2015 at 20:28 UTC | |
by Anonymous Monk on Jan 21, 2015 at 21:28 UTC | |
by Anonymous Monk on Jan 21, 2015 at 21:36 UTC | |
by BillKSmith (Monsignor) on Jan 25, 2015 at 02:39 UTC | |
|
Re: Extract data from non-standard .xml file
by Mr. Muskrat (Canon) on Jan 29, 2015 at 19:05 UTC | |
by BillKSmith (Monsignor) on Jan 29, 2015 at 22:53 UTC | |
|
Re: Extract data from non-standard .xml file
by Anonymous Monk on Jan 30, 2015 at 13:31 UTC |