http://qs321.pair.com?node_id=868104

biswanath_c has asked for the wisdom of the Perl Monks concerning the following question:


Hi

I've read in a few Perl documentation on a few sites that there's an XPath command line utitlity that's useful to test our XPath skills from the command line. I was trying to locate that on my system and was nto able to find it. I also read on a few pages that this tool "requires" the XML::Path and XML::Parser packages; not sure if the tool "comes with" those 2 packages. I was trying to install those 2 packages but was not able to find them using PPM. Can anybody please help me how i can get my hands on the XPath command line utility?


Thanks


Replies are listed 'Best First'.
Re: XPath command line utility...
by ikegami (Patriarch) on Oct 28, 2010 at 18:09 UTC
Re: XPath command line utility...
by kcott (Archbishop) on Oct 28, 2010 at 18:19 UTC

    I suspect you actually want XML::XPath, not XML::Path. That module has an xpath script in the examples directory and it makes reference to ActiveState so that might help with your PPM search.

    -- Ken

      Thanks for the reply. Is that a Perl script? I was actually looking for the command line utility mentioned here on this page: http://www.xml.com/pub/a/2002/04/17/perl-xml.html

        On the subject, the "linked" document says

        Matt Sergeant's fine XML::XPath module provides a way access the contents of XML documents using the W3C-recommended XPath Language. This module also installs a Perl utility called xpath

        So install XML::XPath.

        $ cpan XML::XPath ... Installing /home/eric/usr/perlbrew/perls/perl-5.12.2/bin/xpath ...
Re: XPath command line utility...
by ikegami (Patriarch) on Oct 28, 2010 at 19:11 UTC
    Google finds xpathtool and 4xpath.

    And if you search for "XML utility", you get some GUI tools.

Re: XPath command line utility...
by choroba (Cardinal) on Oct 29, 2010 at 07:29 UTC
    You might also be interested in XML::XSH2, that features the xsh command line and scripting utility.
Re: XPath command line utility...
by graff (Chancellor) on Oct 29, 2010 at 03:12 UTC
    Regarding modules for XML-related work, you may want to try XML::LibXML -- I've found it to be fast, compact, well documented, and fully capable. And it does xpath stuff quite easily. It requires the Gnu LibXML package (available separately, not a Perl thing), which should be readily available for MS systems.

    In fact, LibXML is so easy to use, once I started to grok the XPath usage, I just whipped up a quick command line tool on my own, not even thinking to look for something that someone else might have written already, and it's been working just great:

Re: XPath command line utility...
by mirod (Canon) on Oct 30, 2010 at 12:22 UTC

    If you have XML::LibXML installed you can also try App::xml_grep2, which uses XPath instead of regexps to grep XML files.