Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Search and replace for large number of files

by smls (Friar)
on May 23, 2014 at 10:47 UTC ( [id://1087187]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1087187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2026-04-20 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.