I'm trying to read my Apple Safari history with c#, which is stored in a plist file, however I always get an error and I'm not sure what the correct way is to do it. The code I tried to execute is this:
XmlDocument xmd = new XmlDocument();
xmd.LoadXml(@"C:\Users\Oran\AppData\Roaming\AppleComputer\Safari\History.plist");
and I always get the following error:
"Data at the root level is invalid. Line 1, position 1."
Does anyone know whats wrong with this code and recommend what is the best way to read plist files?
To write out and to parse a plist file, use the dump() and load() functions. To work with plist data in bytes objects, use dumps() and loads() . Values can be strings, integers, floats, booleans, tuples, lists, dictionaries (but only with string keys), bytes , bytearray or datetime.
Launch Finder, click Macintosh HD under Locations. Next, input '. plist' in the searching box on the right top of the window, all the plist files will be listed as follows. Then you can open and edit the plist file in macOS by using Xcode or Apple Property List Editor.
The bplist command shows a list of previously archived or backed up files according to the options that you specify. You can choose the file or directory and the time period that you want the listing to cover.
It looks like that Apple Safari history.plist is binary plist. I've found a great project:
https://github.com/animetrics/PlistCS
From the readme:
This is a C# Property List (plist) serialization library (MIT license). It supports both XML and binary versions of the plist format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With