You need to register the namespace, this is made easy with XML::LibXML::XPathContext:
use XML::LibXML;
use XML::LibXML::XPathContext;
+
my $xml = q{<?xml version="1.0" encoding="iso-8859-1"?>
<Tag1 xmlns="urn:wow">
<Foo>content</Foo>
</Tag1>
};
+
+
+
my $doc = XML::LibXML->new->parse_string($xml);
my $xc = XML::LibXML::XPathContext->new($doc);
$xc->registerNs('foo', 'urn:wow');
+
my ($foo) = $xc->findnodes('//foo:Tag1/foo:Foo');
+
print "Foo in xml: ".$foo->textContent()."\n";
You can register any arbitrary prefix to your namespace URI to use in your XPath expression but note I have changed your namespace to an absolute URI as you get an error from
XML::LibXML otherwise.
/J\