in reply to Search and replace for large number of files

I assume you are using XML::LibXML (good for you!). To work with namespaces, you have to register them and use a prefix:
my $xpc = 'XML::LibXML::XPathContext'->new; $xpc->registerNs('e', 'http://www.earthstats.org/XFDL/Custom'); my @nodes = $xpc->findnodes('e:EARTHSTATS', $xml->documentElement);
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Search and replace for large number of files
by smls (Friar) on May 23, 2014 at 10:47 UTC

    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).

      Thanks for that, I have learnt something new. Looks like I have to change all my other Xpath expressions too though.
Re^2: Search and replace for large number of files
by bangor (Monk) on May 23, 2014 at 11:19 UTC
    Yes, I really like XML::LibXML, it flies through these files some of which are really big. It's the people who produce the XML files in an inconsistent fashion that I want to invite outside!
      I would guess they are using more than 1 application to generate the XML files, so blame the people who wrote those for being inconsistent with the XML specifications.