1XML_GREP(1) User Contributed Perl Documentation XML_GREP(1)
2
3
4
6 xml_grep - grep XML files looking for specific elements
7
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
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 --date
62 when on (by default) the wrapping element get a "date" attribute
63 that gives the date the tool was run.
64
65 with "--nodate" this attribute is not added, which can be useful if
66 you need to compare 2 runs.
67
68 --encoding <enc>
69 encoding of the xml output (utf-8 by default)
70
71 --nb_results <nb>
72 output only <nb> results
73
74 --wrap <tag>
75 wrap the xml result in the provided tag (defaults to 'xml_grep')
76
77 If wrap is set to an empty string ("--wrap ''") then the xml result
78 is not wrapped at all.
79
80 --nowrap
81 same as using "--wrap ''": the xml result is not wrapped.
82
83 --descr <string>
84 attributes of the wrap tag (defaults to "version="<VERSION>"
85 date="<date>"")
86
87 --file_wrap <optional_tag>
88 wrap results for each files into a separate element. By default
89 that element is named "file". It has an attribute named "filename"
90 that gives the name of the file.
91
92 the short version of this option is -g
93
94 --exclude <condition>
95 same as using "-v" in grep: the elements that match the condition
96 are excluded from the result, the input file(s) is (are) otherwise
97 unchanged
98
99 the short form of this option is -v
100
101 --pretty_print <optional_style>
102 pretty print the output using XML::Twig styles ('"indented"',
103 '"record"' or '"record_c"' are probably what you are looking for)
104
105 if the option is used but no style is given then '"indented"' is
106 used
107
108 short form for this arggument is -s
109
110 --text_only
111 Displays the text of the results, one by line.
112
113 Condition Syntax
114
115 <cond> is an XPath-like expression as allowed by XML::Twig to trigger
116 handlers.
117
118 exemples:
119 'para'
120 'para[@compact="compact"]'
121 '*[@urgent]'
122 '*[@urgent="1"]'
123 'para[string()="WARNING"]'
124
125 see XML::Twig for a more complete description of the <cond> syntax
126
127 options are processedby Getopt::Long so they can start with '-' or '--'
128 and can be abbreviated ("-r" instead of "--root" for example)
129
131 xml_grep does a grep on XML files. Instead of using regular expressions
132 it uses XPath expressions (in fact the subset of XPath supported by
133 XML::Twig)
134
135 the results can be the names of the files or XML elements containing
136 matching elements.
137
139 XML::Twig Getopt::Long
140
142 This library is free software; you can redistribute it and/or modify it
143 under the same terms as Perl itself.
144
146 Michel Rodriguez <mirod@xmltwig.com>
147
148
149
150perl v5.8.8 2007-01-21 XML_GREP(1)