2008-07-15: Selected articles now have experimental "comment" links in the left column and at the bottom. You're welcome to use them for commenting and voting on articles. For a bit more on this, see this page. /F

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…

 

A Django site. this page was rendered by a django application in 0.02s 2008-07-20 23:34:03.833639. hosted by webfaction.