hi frnds, i want to get the safari history in VB.Net..Safari maintains its history in history.plist file.....I want to know that how to convert this file to XML format??Plz help me out from where to start,,,cz i have no idea..

Dani AI

Generated

Short summary and quick diagnosis: Bookmarks.plist can be either XML or Apple’s binary plist format — that explains seeing XML in some cases and seeing unreadable bytes. Quick test: open the file as bytes and check the first 8 characters for the ASCII header bplist00 (that identifies a binary plist). If it’s not bplist00 you already have XML and can parse it with any XML API. (developer.apple.com)

If you have a Mac, use the built‑in tool to convert in place or to stdout. Example (run on a copied file; don’t edit Safari’s live file while Safari is running):

/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist > ~/Desktop/Bookmarks.xml

That writes XML to stdout (or use -o outputfile to write a file). plutil/plistutil are the standard tools for converting plist formats. Always work on a copy first. (libimobiledevice.org)

If you’re on Windows or want a scriptable approach, Python’s stdlib plistlib reads binary plists and can dump XML — handy for automated conversion:

import plistlib
with open('Bookmarks.plist','rb') as f:
    data = plistlib.load(f)
with open('Bookmarks.xml','wb') as f:
    plistlib.dump(data, f, fmt=plistlib.FMT_XML)

plistlib autodetects binary vs XML. Alternatively, use a .NET plist library (PList‑Net, PlistAPI, etc.) to read binary plists directly from VB/C# without converting files first. (docs.python.org)

Suggested workflow and troubleshooting: 1) copy Bookmarks.plist to a safe folder, 2) detect header (bplist00 versus XML), 3a) if binary — convert (plutil or Python) or parse directly with a .NET plist library, 3b) if XML — use XmlReader/XmlDocument in VB.NET to walk dict/array nodes, and 4) don’t write back into Safari’s live file while the browser runs. If a converted XML still looks odd, the file may contain archived Cocoa objects (NSKeyedArchiver) and will need a higher‑level parser or library to decode those values. (developer.apple.com)

Recommended Answers

All 5 Replies

I don't use Safari but I have it installed (version 3.2.2 (525.28.1)). I took a quick look at history.plist and it looks like valid XML to me. I also changed the file extension to xml and it opened with my xml editor without errors.

Maybe you don't have to do any conversion at all? Have you tried reading it with VB.NET (XmlReader or whatever you want to do with the file)?

Sorry its not History.plist file its Bookmarks.plist file,Its in binary format..open it .I want to convert it XML format so dat i can retch bookmarks from it......

:-/ Bookmarks.plist seems valid XML too...

No frnd bookmarks file is not in XML format......Cz XML file can be raed in simple format...

If Dir(sFileName) <> "" Then
                FileOpen(FileNum, Application.StartupPath & "\" & IGNORE_LIST_PATH, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
                Do While Not EOF(FileNum)
                    sInputLine = LineInput(FileNum)
                Loop
End If

When i read the history.plist with the above code,it is raeding..But when i raed the Bookmarks.Plist file...It is raeding,but data returned is not correctly..
have a look again at the Boomarks,Plist..Althought u can view the view contents of the file. Plz raed the file U will come to know what i m sayg??

Worked fine with the following code. Never hit the "breakpoint" lines

Dim sFileName As String
Dim FileNum As Integer
Dim sInputLine As String

sFileName = "C:\Documents and Settings\<user>\Application Data\Apple Computer\Safari\bookmarks.plist"
FileNum = FreeFile()
If Dir(sFileName) <> "" Then
  Try
    FileOpen(FileNum, sFileName, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
  Catch ex As Exception
    ex = ex ' Breakpoint line
  End Try
  Do While Not EOF(FileNum)
    Try
      sInputLine = LineInput(FileNum)
    Catch ex As Exception
      ex = ex ' Breakpoint line
    End Try
  Loop
End If

' Second way
If My.Computer.FileSystem.FileExists(sFileName) Then
  sInputLine = My.Computer.FileSystem.ReadAllText(sFileName)
End If

I also renamed again bookmarks.plist -> bookmarks.xml and opened it with my xml-editor w/o any problems i.e. the editor marked the content as valid xml.

Have you opened your bookmarks.plist with an hex-editor and checked for "binary" characters (except CR and/or LF chars)? Have you tried to open it with an xml editor? (There are freeware editors in the net if you don't have a suitable editor.)

Also, have you tried to read bookmarks.plist with XmlReader instead as a text file? You can google VB.NET+"how to read xml file" to get sample codes for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.