PHPackages                             kafene/netscape-bookmark-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kafene/netscape-bookmark-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kafene/netscape-bookmark-parser
===============================

Generic Netscape bookmark parser

v0.0.1(10y ago)43419↓66.7%23[2 issues](https://github.com/kafene/netscape-bookmark-parser/issues)MITPHP

Since Sep 17Pushed 8y ago4 watchersCompare

[ Source](https://github.com/kafene/netscape-bookmark-parser)[ Packagist](https://packagist.org/packages/kafene/netscape-bookmark-parser)[ Docs](https://github.com/kafene/BookmarkParser)[ RSS](/packages/kafene-netscape-bookmark-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

netscape-bookmark-parser
========================

[](#netscape-bookmark-parser)

[![license](https://camo.githubusercontent.com/28dd921bc308dc2b65d832f290a28c3a99279b4a0fb66eb2093c20f9b1ec8b7e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6166656e652f6e657473636170652d626f6f6b6d61726b2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

[![](https://camo.githubusercontent.com/a6cc2968ba395308353245da93b23a8f772442557c7c9ae99a48ea830f6f2514/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6166656e652f6e657473636170652d626f6f6b6d61726b2d7061727365722e7376673f7374796c653d706c6173746963)](https://packagist.org/packages/kafene/netscape-bookmark-parser)

About
-----

[](#about)

This library provides a generic `NetscapeBookmarkParser` class that is able of parsing Netscape bookmark export files.

The motivations behind developing this parser are the following:

- the [Netscape format](https://msdn.microsoft.com/en-us/library/aa753582%28v=vs.85%29.aspx)has a very loose specification: no [DTD](https://en.wikipedia.org/wiki/Document_type_definition)nor [XSL stylesheet](https://en.wikipedia.org/wiki/XSL)to constrain how data is formatted
- software and web services export bookmarks using a wild variety of attribute names and values
- using standard SAX or DOM parsers is thus not straightforward.

How it works:

- the input bookmark file is trimmed and sanitized to improve parsing results
- the resulting data is then parsed using [PCRE](http://www.pcre.org/) patterns to match attributes and values corresponding to the most likely:
    - attribute names: `description` vs. `note`, `tags` vs. `labels`, `date` vs. `time`, etc.
    - data formats: `comma,separated,tags` vs. `space separated labels`, UNIX epochs vs. human-readable dates, newlines &amp; carriage returns, etc.
- an associative array containing all successfully parsed links with their attributes is returned

Example
-------

[](#example)

Script:

```
