Importing bookmark.htm
page 1 of 1
Published: 30 Oct 2003
Unedited - Community Contributed
Abstract
I look at how to use regular expressions to extract all the relevant information from Netscape’s bookmark file.
by Damian Manifold
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 11864/ 17

Importing bookmark.htm with Reqular Expressions
Importing bookmark.htm with Reqular Expressions
by Damian Manifold

The one good thing about Netscape is the bookmark.htm file, if you have ever tried to copy all your URL files to a disk you know how much longer it takes, and as for uploading a URL file, forget about it.

Here we will be looking at how to extract the bookmarks from the file.

Source Code
Import.aspx Import bookmark example
Import.aspx.vb Code behind

Now getting the href from and anchor tag is quite easy. Here we are going to be extracting the path to the bookmark, and it is this which makes it a little more difficult.

The regular expression we use to do this is massive.

Import.aspx.vb sample 1 Generated using CodeView

But do not worry; it is actually 3 straight forward expressions joined together.
This is an example of using | (or) to select between 1 of the 3 patterns we are interested in.

  • an anchor tag, containing information about the bookmark
  • a folder title, indicating entry into a new folder
  • the literal </DL><p>, indicating the end of a folder

Once you have extracted the bookmarks, you can display them in your own format, or go that little bit further are check that none of them are dead links.

Examples
Import.aspx Import in action

You might notice from the example that the dates are a little old. This is due the fact that the bookmark.htm was created with a utility that does not really bother with the dates when converting. The code does work fine with a Netscape produced bookmark.htm

Articles
How to check URLs using .NET By Damian Manifold

Links
Bookmark Converter 2.x a nice utility to convert you URLs to a bookmark.htm , and back again



User Comments

Title: Excellent   
Name: Rahul
Date: 2008-09-24 9:51:12 AM
Comment:
hi,
i got much more information from your article, but i am searching for some more

Once user has added my web page to bookmarks and visits again to the page he should not bookmark again the same web page

If you have any information please send me on
rahulhanchate@reportinghouse.com
Title: Excellent   
Name: Geetu
Date: 2006-09-22 9:12:45 AM
Comment:
Hi,
Your aticle has done magic for me......
I want to implement the functionality of exporting and importing the bookmarks to my website....
I got an idea how i can implement the logic in any application.

But i m still confused how to export the bookmarks stored in my Database as HTML file

Pls if u have any idea then let me know......
My id is geetanjali.sharma@redalkemi.com

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 3:33:09 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search