Intelligent XML/HTML Parsing: Firefox/Netscape Bookmarks.html Format

Hi,
I have a question on how to parse/edit an html file with a specific format. I'm talking about the Firefox/Netscape's bookmarks.html format. Is there an easy way to write new bookmarks (essentially link and text in according to specified spec) to this file format I'm thinking is there a way to convert this format into an XML object in the .NET XML object format and manipulate it that way

Please give me any thoughts you have on this specific problem, or the general problem at large.

Thanks.


Answer this question

Intelligent XML/HTML Parsing: Firefox/Netscape Bookmarks.html Format

  • sparecycles

    Jeff,

    The exported bookmarks file that firefox creates is not a valid xml.

    If you examine the file it has <DT> tag before each bookmark, but this tag is not closed after the bookmark link.

    So as it's not possible to read/write an bad structured XML, you have to use a text writer if you want to create the same exact file structure.

    But you may modify the file, correcting tags, and then you can feed the file to xsd.exe and create vb or c# classes that when serialized creates the same structure.

    xsd.exe would help you to accomplish that.

    Thanks,

    Sinan



  • Nightman28

    Is there an easy way to write new bookmarks (essentially link and text in according to specified spec) to this file format

    You may use the File.ReadAllLines method and insert new bookmarks just before the final "</DL><p>" line. However, if Firefox/Netscape is running, it may overwrite your changes.

    I'm thinking is there a way to convert this format into an XML object in the .NET XML object format and manipulate it that way

    Yes. For example, you may use SgmlReader or .NET Html Agility Pack.

    Best regards,
    Anton


  • Intelligent XML/HTML Parsing: Firefox/Netscape Bookmarks.html Format