grep(1) for XML, using XPath (or CSS selectors) instead of regex(3).
* Searches XML documents for elements matching a given XPath expression or CSS
selector (anything Hpricot knows about).
* Command-line switches are the same as grep(1) where sensible and implemented.
$ xpgrep --help
Usage: /usr/bin/xpgrep [options] <xpath-or-css-expr> <file [file ...]>
-H, --with-filename print the filename for each match
-h, --no-filename suppress printing filename for matches
-l, --files-with-matches only print filenames containing matches
-L, --files-without-match only print filenames containing no match
-e, --extract <attr> extract the value of the given attribute
-t, --html parse file(s) as HTML
--help print this message and exit
$ gem install xpgrep
After checking out the source, run:
$ rake newb
This task will install any missing dependencies, run the tests/specs,
and generate the RDoc.
(GNU General Public License v2.0)
Copyright (C) 2010 Kevin R. Bullock
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.