1XML_GREP(1)           User Contributed Perl Documentation          XML_GREP(1)
2
3
4

NAME

6       xml_grep - grep XML files looking for specific elements
7

SYNOPSYS

9         xml_grep [options] <file list>
10
11       or
12
13         xml_grep <xpath expression> <file list>
14
15       By default you can just give "xml_grep" an XPath expression and a list
16       of files, and get an XML file with the result.
17
18       This is equivalent to writing
19
20         xml_grep --group_by_file file --pretty_print indented --cond <file list>
21

OPTIONS

23       --help
24           brief help message
25
26       --man
27           full documentation
28
29       --Version
30           display the tool version
31
32       --root <cond>
33           look for and return xml chunks matching <cond>
34
35           if neither "--root" nor "--file" are used then the element(s) that
36           trigger the "--cond" option is (are) used. If "--cond" is not used
37           then all elements matching the <cond> are returned
38
39           several "--root" can be provided
40
41       --cond <cond>
42           return the chunks (or file names) only if they contain elements
43           matching <cond>
44
45           several "--cond" can be provided (in which case they are OR'ed)
46
47       --files
48           return only file names (do not generate an XML output)
49
50           usage of this option precludes using any of the options that define
51           the XML output: "--roots", "--encoding", "--wrap",
52           "--group_by_file" or "--pretty_print"
53
54       --count
55           return only the number of matches in each file
56
57           usage of this option precludes using any of the options that define
58           the XML output: "--roots", "--encoding", "--wrap",
59           "--group_by_file" or "--pretty_print"
60
61       --strict
62           without this option parsing errors are reported to STDOUT and the
63           file skipped
64
65       --date
66           when on (by default) the wrapping element get a "date" attribute
67           that gives the date the tool was run.
68
69           with "--nodate" this attribute is not added, which can be useful if
70           you need to compare 2 runs.
71
72       --encoding <enc>
73           encoding of the xml output (utf-8 by default)
74
75       --nb_results <nb>
76           output only <nb> results
77
78       --by_file
79           output only <nb> results by file
80
81       --wrap <tag>
82           wrap the xml result in the provided tag (defaults to 'xml_grep')
83
84           If wrap is set to an empty string ("--wrap ''") then the xml result
85           is not wrapped at all.
86
87       --nowrap
88           same as using "--wrap ''": the xml result is not wrapped.
89
90       --descr <string>
91           attributes of the wrap tag (defaults to "version="<VERSION>"
92           date="<date>"")
93
94       --group_by_file <optional_tag>
95           wrap results for each files into a separate element. By default
96           that element is named "file". It has an attribute named "filename"
97           that gives the name of the file.
98
99           the short version of this option is -g
100
101       --exclude <condition>
102           same as using "-v" in grep: the elements that match the condition
103           are excluded from the result, the input file(s) is (are) otherwise
104           unchanged
105
106           the short form of this option is -v
107
108       --pretty_print <optional_style>
109           pretty print the output using XML::Twig styles ('"indented"',
110           '"record"' or '"record_c"' are probably what you are looking for)
111
112           if the option is used but no style is given then '"indented"' is
113           used
114
115           short form for this argument is -s
116
117       --text_only
118           Displays the text of the results, one by line.
119
120       --html
121           Allow HTML input, files are converted using HTML::TreeBuilder
122
123       --Tidy
124           Allow HTML input, files are converted using HTML::Tidy
125
126   Condition Syntax
127       <cond> is an XPath-like expression as allowed by XML::Twig to trigger
128       handlers.
129
130       exemples:
131         'para'
132         'para[@compact="compact"]'
133         '*[@urgent]'
134         '*[@urgent="1"]'
135         'para[string()="WARNING"]'
136
137       see XML::Twig for a more complete description of the <cond> syntax
138
139       options are processedby Getopt::Long so they can start with '-' or '--'
140       and can be abbreviated ("-r" instead of "--root" for example)
141

DESCRIPTION

143       xml_grep does a grep on XML files. Instead of using regular expressions
144       it uses XPath expressions (in fact the subset of XPath supported by
145       XML::Twig)
146
147       the results can be the names of the files or XML elements containing
148       matching elements.
149

SEE ALSO

151       XML::Twig Getopt::Long
152

LICENSE

154       This library is free software; you can redistribute it and/or modify it
155       under the same terms as Perl itself.
156

AUTHOR

158       Michel Rodriguez <mirod@xmltwig.com>
159
160
161
162perl v5.16.3                      2012-05-17                       XML_GREP(1)
Impressum