http://www.perlmonks.org?node_id=811863


in reply to Re: XPATH DOM traverse html/xml
in thread XPATH DOM traverse html/xml

XML::Twig is one of the many things that keeps me using Perl. (It's one of the modules my personal 'M.pm' module loads -- 'M.pm' so I can do perl -MM -lwe ....) So, thanks again, mirod.

The first thing that came to mind was:

perl -MXML::Twig -E 'XML::Twig->new( twig_handlers => { _all_ => sub { say $_->xpath } })->parsefile(shift)'

...which isn't so different from what you wrote. But, the following has the benefit of not requiring the loading of the entire file (correct?):

perl -MXML::Twig -E 'XML::Twig->new( start_tag_handlers => { _all_ => sub { say $_->xpath } })->parsefile(shift)'