#!/usr/bin/perl use strict; use warnings; use XML::LibXML; use XML::LibXML::XPathContext; # load the XML doc my $p = XML::LibXML->new; my $xml_file = do { local $/; }; my $dom = $p->parse_string( $xml_file ); # register the namespace my $xc = XML::LibXML::XPathContext->new( $dom ); $xc->registerNs('ns', 'http://www.mydomain.com'); # select using XPath my @nodes = $xc->findnodes( '/ns:info/ns:city'); print $_->toString for @nodes; __DATA__ john baltimore 21205