Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing .plist Files to plain XML C#

Tags:

c#

plist

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?

like image 755
Oran Avatar asked Oct 25 '10 12:10

Oran


People also ask

How do I parse a plist file?

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.

How do I read Apple plist files?

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.

What is a Bplist?

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.


1 Answers

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.

like image 150
Kluyg Avatar answered Oct 30 '22 14:10

Kluyg