Netscape::Bookmarks::Category - manipulate, or create Netscape Bookmarks files


Netscape::Bookmarks::Category - manipulate, or create Netscape Bookmarks files


  use Netscape::Bookmarks;
  #parse an existing file
  my $bookmarks = new Netscape::Bookmarks $bookmarks_file;
  #print a Netscape compatible file
  print $bookmarks->as_string;


The Netscape bookmarks file has several basic components:

        folders (henceforth called categories)

On disk, Netscape browsers store this information in HTML. In the browser, it is displayed under the ``Bookmarks'' menu. The data can be manipulated through the browser interface.

This module allows one to manipulate the bookmarks file programmatically. One can parse an existing bookmarks file, manipulate the information, and write it as a bookmarks file again. Furthermore, one can skip the parsing step to create a new bookmarks file and write it in the proper format to be used by a Netscape browser.

The module simply parses the bookmarks file passed to it as the only argument to the constructor:

        my $bookmarks = new Netscape::Bookmarks $bookmarks_file;

The returned object is a Netscape::Bookmarks::Category object, since the bookmark file is simply a collection of categories that contain any of the components listed above. The top level (i.e. root) category is treated specially and defines the title of the bookmarks file.


Netscape::Bookmarks::Category->new( \%hash )
The new method creates a Category. It takes a hash reference that specifies the properties of the category. The valid keys in that hash are
        folded                  collapsed state of the category ( 1 or 0 )

$category->add( $object )
The add() function adds an element to a category. The element must be a Alias, Link, Category, or Separator object. Returns TRUE or FALSE.

$category->add_desc( $object )
Adds a description to the category.

Returns title to the category.

Returns the ID of the category. This is an arbitrary, unique number.

Returns the description of the category

$category->folded( $object )
Returns the folded state of the category (TRUE or FALSE). If the category is ``folded'', Netscape shows a collapsed folder for this category.

Returns the ADD_DATE attribute of the category.

Returns an array reference to the elements in the category.

Returns a list of the Category objects in the category.

Returns a list of the Link objects in the category.

Returns an HTML string representation of the category, but not the elements of the category.

Returns an HTML string representation of the category as the top level category, along with all of the elements of the category and the Categories that it contains, recursively.


This source is part of a SourceForge project which always has the latest sources in CVS, as well as all of the previous releases.

If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.


brian d foy, <>


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

If you send me modifications or new features, I will do my best to incorporate them into future versions. You can interact with the Sourceforge porject for this module at


the Netscape::Bookmarks manpage

 Netscape::Bookmarks::Category - manipulate, or create Netscape Bookmarks files