Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Help debugging xpath in Perl

by choroba (Cardinal)
on Mar 12, 2021 at 19:27 UTC ( [id://11129527]=note: print w/replies, xml ) Need Help??


in reply to Help debugging xpath in Perl

It seems XML::Twig doesn't understand /text(). But maybe you don't need it? This seems to work:
'//*[@name="FilterName"]/*' => sub {print $_->text}

If you want to use the full XPath, switch to XML::LibXML. For large files, you can use its XML::LibXML::Reader. To experiment with XPath, you can use XML::XSH2, which is like xmllint combined with Perl.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Help debugging xpath in Perl
by tweetiepooh (Hermit) on Mar 17, 2021 at 09:34 UTC
    Super, that cracked it. Many thanks. Now to pull all the little bits of data together.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-19 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found