in reply to Re: Search and replace for large number of files
in thread Search and replace for large number of files

To catch both cases in one go, you could use an alternation inside the XPath expression:

my @nodes = $xpc->findnodes('e:EARTHSTATS | EARTHSTATS', $doc);

An alternative solution that does not require registering the namespace, would be to use the local-name XPath function:

my @nodes = $doc->findnodes('*[local-name()="EARTHSTATS"]');

Of course neither of those solutions is very pretty, but unfortunately that's just how XPath 1.0 works when dealing with inconsistently namespaced input.
Things are better with XPath 2, but XML::LibXML doesn't have support for that (nor does any other Perl module that I'm aware of).

Replies are listed 'Best First'.
Re^3: Search and replace for large number of files
by bangor (Monk) on May 23, 2014 at 11:16 UTC
    Thanks for that, I have learnt something new. Looks like I have to change all my other Xpath expressions too though.