We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

Using Element Trees to Parse XBEL Files

July 15, 2002 | Fredrik Lundh

The XML Bookmark Exchange Language (XBEL) is a simple XML format that can be used to store “bookmark collections” as used by Internet browsers.

Parsing XBEL Files

XBEL files are ordinary XML files. Just parse them, and you’re done:

import elementtree.ElementTree as ET

bookmarks = ET.parse("bm1.xbel")

for bookmark in bookmarks.getiterator("bookmark"):
    print bookmark.get("href"), bookmark.findtext("title")

Merging XBEL Files

Over at the ASPN Cookbook, Uche Ogbuji has posted a 90 line script which merges two XBEL bookmark files.

My ElementTree version isn’t quite ready for public consumption, but I can assure you that it’s a little bit shorter… ;-)

To be continued…