Hi fellow monks.
I'm using XML::LibXML to edit xml files but I'm stucked to this problem:
When the root element of my document has an xmlns attributes, the findnodes method fails to give me the node I want.
Here is a test code:
use XML::LibXML ;
my $xml = q{<?xml version="1.0" encoding="iso-8859-1"?>
<Tag1 xmlns="wow">
<Foo>content</Foo>
</Tag1>
};
my $xml2 = q{<?xml version="1.0" encoding="iso-8859-1"?>
<Tag1>
<Foo>content</Foo>
</Tag1>
};
my $parser = XML::LibXML->new();
my $doc1 = $parser->parse_string($xml);
my ($foo) = $doc1->findnodes('/Tag1/Foo');
print "Foo in xml: ".$foo."\n"; ## Gives undef (with xmlns)
my $doc2 = $parser->parse_string($xml2);
my ($foo2) = $doc2->findnodes('/Tag1/Foo'); ## IS OK (without xmlns)
print "Foo in xml2: ".$foo2->textContent()."\n" ;
Can anybody help ?
I searched how to make the parser namespace negligent but I didn't find.
Thanks .
J.
--
Nice photos of naked perl sources here !