in reply to Mechanize to TreeBuilder-XPath

If you want to stick with Mechanize then use use Mojo::DOM; to parse that content you got from $mech and convert it to DOM
use Mojo::DOM; my $dom = Mojo::DOM->new($mech->content()); print "Title: ".$dom->html->head->title;