Thank you very much for this information. I started doing it with nokogiri as well (before my first post).
At first glance this looks like something i could use.
I might base part of my code of yours. It is for my masters thesis, and i will of course mention you (at least in the code base.)