There are other ways of doing this, but I thought it would be fun to write a command-line xpath script in ruby using rexml. (full working example here) Read more