For your first problem, it sounds like you should be using XSLT: http://greg.rubyfr.net/pub/packages/ruby-xslt/files/README.html
For your second, I've never heard of XPath being used for this, but I could be wrong. It sounds like you'll just have to write your own compare function that will emit nodes that have changed.