summaryrefslogtreecommitdiffstats
path: root/gxpp.1
blob: 7c7f9b5aabbd1fe0e7ee3548a9c7238f938294ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
.TH GXPP 1 "3 July 2008"
.SH NAME
gxpp \- print elements matching an XPath expression
.SH SYNOPSIS
\fBgxpp\fR [\fIoptions\fR] \fIXPATH \fR[\fIFILE\fR...]
.SH DESCRIPTION

.B Gxpp
prints the results of an XPath expression when applied to the
specified XML document or standard input.

.SH OPTIONS

.TP
.B \-c
Print the count of the expression matches instead of printing the
matches.

.TP
.B \-H
Print the filename for each match.

.TP
.B \-h
Suppress the printing of filenames when multiple files are specified.

.TP
.B \-L
Suppress normal output; instead print the name of each input document for which the XPath expression does not match.

.TP
.B \-l
Suppress normal output; instead print the name of each input document for which the XPath expression matches.

.TP
.BI \-p " PRE"
The prefix to use in the XPath expression to match the default XML
name space in the document.  XPath 1.0 does not define a way to match
the default name space when an XML document contains XML name spaces.
By specifying a default name space prefix here, you can match on the
default prefix in the document.

.TP
.B \-q
Exit with the normal exit status, but don't generate any output.

.TP
.B \-x
Print the XML sub-tree(s) which match the XPath expression instead of
the contents of the XML elements.

.SH EXAMPLES
.nf
.B Example document
<A>
 <B name="foo">
  <C>C of foo</C>
 </B>
 <B name="bar">
  <C>C of bar</C>
 </B>
 <B name="baz">
  <C>C of baz</C>
 </B>
</A>

.B # gxpp /A/B/@name example.xml 
foo
bar
baz

.B # gxpp  -c /A/B/@name example.xml 
3

.B # gxpp  -x "/A/B[@name='baz']" example.xml 
<B name="baz">
 <C>C of baz</C>
</B>

.B # gxpp  "/A/B[@name='bar']/C" example.xml 
C of bar

.B # gxpp  //C example.xml 
C of foo
C of bar
C of baz

.fi
.SH "SEE ALSO"
gxpd(1), grep(1), http://www.w3.org/TR/xpath