#!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML; my $parser = XML::LibXML->new; $parser->recover_silently( 1 ); my $doc = $parser->parse_file( 'http://www.heise.de/' ); my $xc = XML::LibXML::XPathContext->new( $doc->getDocumentElement ); $xc->registerNs( 'xmlns', 'http://www.w3.org/1999/xhtml' ); my $nodes = $xc->findnodes( '//xmlns:h2/xmlns:a' ); for my $node ( $nodes->get_nodelist ) { say $_->getName, '=', $_->getValue for $node->attributes; } say "\n----------------------------------------\n"; $doc = $parser->parse_file( 'http://www.orf.at/' ); $nodes = $doc->findnodes( '//frame' ); for my $node ( $nodes->get_nodelist ) { say $_->getName, '=', $_->getValue for $node->attributes; }