Updated detect code to use XPaths instead of regexes, to constrain possible
matches more tightly.