Re: File_Format_Bookmarks

From: Date: Wed, 28 Jul 2004 10:23:29 +0000
Subject: Re: File_Format_Bookmarks
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13883@lists.php.net to get a copy of this message
"Matthias H. Risse" <usenet@risse.org> wrote: > Hi! > > Anyone knows of a package that handles Netscape bookmark files which are > shipping with Mozilla Suite, Firefox and Co.? > > The strucuture of the format is kinda strange, even the > tags are not properly nested (check <p> tags) so this implies > there a k-free grammar or DTD cannot not exist plus domxml-parsers > wont read those files.... It looks like valid SGML. > Example: > > [..] > <DL><p> > <DT><A ..>bookmark1</A> > <DT><A ..>bookmark2</A> > <DT><A ..>bookmark3</A> > </DL><p> > [..] > > Any regex hero around who has solved this problem > so far and provides/ed a nice API? Here's a GPL'd project you might be interested in: http://www2.fht-esslingen.de/~clfuit00/sasnt/bk_edit/ It's not PHP, but still may give you some pointers. Here's a dirty way of parsing it: <?php $file = file_get_contents('/path/to/bookmark.htm'); $clean = strreplace('<p>', '', $file); // parse the file as you like -- remember that you want // to have upper case tags $final = strreplace('<DL>', '<DL><p>', $parsed); // now put it in a file ?> This is a quick hack, and I've not tested it, but it should work fine :-) hth, Klaus

« previous php.pear.general (#13883) next »