1xgrep(1)                    General Commands Manual                   xgrep(1)
2
3
4

NAME

6       xgrep ‐ search content of an XML file
7

SYNOPSIS

9       xgrep  [-h]  [-v]  [-t]  [-p]  [-n  nsdef [-n nsdef]...] [-x xpath] [-s
10       string [-s string]...] [-c catalog-file] [infile [infile]...]
11

DESCRIPTION

13       xgrep provides facilities for  searching  content  in  XML  files.  The
14       search  is  specified  either  as an XPath via the -x flag, or a custom
15       syntax including extended regular expressions via the -s flag.   Multi‐
16       ple  input  files may be specified; if none are provided, input is read
17       from stdin.
18

OPTIONS

20       xgrep accepts the following options:
21
22       -x xpath
23               An XPath specification of the elements of interest.
24
25       -s string
26               A custom string format specifying the elements of interest. The
27               string format is base-element:element/regex/,element/regex/,...
28               where base-element is the name of the elements within  which  a
29               match  should  be  attempted, the match succeeding if, for each
30               element/regex/ pair, the content of an element of that name  is
31               matched  by  the  corresponding regex. If multiple -s flags are
32               specified, a match by any one of them is returned.
33
34       -n nsdef
35               Define a namespace prefix using the form prefix=namespace.
36
37       -c catalog-file
38               Use the specified catalog file instead of the default.
39
40       -p      Regular expressions use Perl syntax as implemented in the  PCRE
41               library. (This option only available when xgrep has been linked
42               with the PCRE library.)
43
44       -t      Text output mode for generating output formatted for subsequent
45               processing  by  standard  command-line  text  tools (grep, sed,
46               etc.). Linefeeds are converted to spaces within  each  matching
47               node set, and each node set is seperated by a newline.
48
49       -h      Display usage information
50
51       -v      Display version information
52

EXAMPLES

54       Consider an XML format, for personnel information, in which each person
55       element has descendant elements called name and hiredate. To  find  all
56       person  elements  with  "Smith"  in the content of the name element and
57       "2000" in the content of the hiredate element, do:
58
59           xgrep -s 'person:name/Smith/,hiredate/2000/' a.xml b.xml
60
61       Using XPath to locate elements with a namespace requires use of the  -n
62       flag  to define a namespace prefix for use in the XPath. For example to
63       search for "name" elements within a GPX document, do:
64
65           xgrep -n gpx="http://www.topografix.com/GPX/1/1" \
66                 -x '//gpx:name' data.gpx
67
68
69

SEE ALSO

71       regex(7), pcre(3), xmllint(1)
72

AUTHOR

74       Brendt Wohlberg <software@wohlberg.net>
75
76
77
78                                 9 August 2013                        xgrep(1)
Impressum