#!/usr/bin/perl use strict; use warnings; use LWP; use Data::Dumper; my $browser = LWP::UserAgent->new(); my $site = $browser->get('http://de.wikibooks.org'); my $code = $site->decoded_content(); use XML::LibXML; my $dom = XML::LibXML->load_xml(string => $code); foreach my $node ($dom->findnodes('//link[@rel="canonical"]/@href')) { print $node->to_literal(), " # canonical LibXML\n"; } use XML::XPath; my $xp = XML::XPath->new(xml => $code); foreach my $node ($xp->findnodes('//link[@rel="canonical"]')) { print $node->getAttribute('href'), " # canonical XPath\n"; }