WWW::Scripter – search.cpan.org
From the POD there:
DESCRIPTION
This is a subclass of WWW::Mechanize that uses the W3C DOM and provides support for scripting.
No actual scripting engines are provided with WWW::Scripter, but are available as separate plugins. (See also the “SEE ALSO” section below.)
So it supports DOM, but no XPath expression yet.
And there is Javascript support through plugins.