REXML and XPath

For your first problem, it sounds like you should be using XSLT:

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.