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       --wrap <tag>
79           wrap the xml result in the provided tag (defaults to 'xml_grep')
80
81           If wrap is set to an empty string ("--wrap ''") then the xml result
82           is not wrapped at all.
83
84       --nowrap
85           same as using "--wrap ''": the xml result is not wrapped.
86
87       --descr <string>
88           attributes of the wrap tag (defaults to "version="<VERSION>"
89           date="<date>"")
90
91       --group_by_file <optional_tag>
92           wrap results for each files into a separate element. By default
93           that element is named "file". It has an attribute named "filename"
94           that gives the name of the file.
95
96           the short version of this option is -g
97
98       --exclude <condition>
99           same as using "-v" in grep: the elements that match the condition
100           are excluded from the result, the input file(s) is (are) otherwise
101           unchanged
102
103           the short form of this option is -v
104
105       --pretty_print <optional_style>
106           pretty print the output using XML::Twig styles ('"indented"',
107           '"record"' or '"record_c"' are probably what you are looking for)
108
109           if the option is used but no style is given then '"indented"' is
110           used
111
112           short form for this arggument is -s
113
114       --text_only
115           Displays the text of the results, one by line.
116
117   Condition Syntax
118       <cond> is an XPath-like expression as allowed by XML::Twig to trigger
119       handlers.
120
121       exemples:
122         'para'
123         'para[@compact="compact"]'
124         '*[@urgent]'
125         '*[@urgent="1"]'
126         'para[string()="WARNING"]'
127
128       see XML::Twig for a more complete description of the <cond> syntax
129
130       options are processedby Getopt::Long so they can start with '-' or '--'
131       and can be abbreviated ("-r" instead of "--root" for example)
132

DESCRIPTION

134       xml_grep does a grep on XML files. Instead of using regular expressions
135       it uses XPath expressions (in fact the subset of XPath supported by
136       XML::Twig)
137
138       the results can be the names of the files or XML elements containing
139       matching elements.
140

SEE ALSO

142       XML::Twig Getopt::Long
143

LICENSE

145       This library is free software; you can redistribute it and/or modify it
146       under the same terms as Perl itself.
147

AUTHOR

149       Michel Rodriguez <mirod@xmltwig.com>
150
151
152
153perl v5.12.0                      2009-11-10                       XML_GREP(1)
Impressum