Saving url history ?

Looking for a way to save url history, considering xml. I can use XMLDocument / elements etc., but no idea how to create an xml file and write to it, epsecially if I can write on the fly ?


I can consider other options.

Replies

Are you exporting this URL history? Or is this your working format (meaning you’ll have to append entries to the end of the history, remove entries from the start, and so on)?

What platform are you working on?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Not exporting, for in app use only. I want to make a page from it which is why I'm considering xml, so navigated just like a regular webpage. I want to append entries as and when they happen, maybe remove after a time period.


Platform? OS X.

XML is not an easy format to modify in place. Most XML APIs expect you to write the entire XML document, and NSXMLDocument is no exception. That leaves you with a bunch of options:

  • A — You can store the actual URLs in a database (Core Data, or ***** SQLite) and then export it XML using NSXMLDocument (and libxml2’s xmlwriter API, which is likely to be much faster).

  • B — You can use NSXMLDocument to read/modify/write the XML document.

  • C — You can do something custom. For example, if you hard-wire knowledge about the XML format into your app, you could open the file, seek back a fixed amount to get to the start of the XML trailer, and then write your new entry along with a new XML trailer.

Which option you choose depends on how much data you’re dealing with, and what your access patterns look like. For example, option B would be the easiest approach but it’s unlikely to scale well. OTOH, option A is likely to scale well (especially if you do a lazy export) and will be more flexible if you need to do database-like things (like removing all the entries older than a certain date). I’d only do option C if you’re absolutely wedded to XML and you’re dealing with very large data sets.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"