1
2ethxmlextract(8) EFSFFCLIRG (Man Page) ethxmlextract(8)
3
4
5
7 ethxmlextract
8
9
10
11 Extracts element values from XML input and outputs the data in CSV for‐
12 mat. ethxmlextract is intended to be used with ethreport, to parse and
13 filter its XML output, and to allow the filtered output to be imported
14 into other tools such as spreadsheets and customer-written scripts.
15 ethxmlextract can also be used with any well-formed XML stream to ex‐
16 tract element values into a delimited format.
17
18 Five sample scripts are available as prototypes for customized scripts.
19 They combine various calls to ethreport with a call to ethxmlextract
20 with commonly used parameters.
21
23 ethxmlextract [-v][-H][-d delimiter][-e extract_element]
24
25 [-s suppress_element][-X input_file] [-P param_file]
26
28 --help
29
30 Produces full help text.
31
32
33 -v/--verbose
34
35 Produces verbose output. Includes output progress reports
36 during extraction and output prepended wildcard characters on
37 element names in output header record.
38
39
40 -H/--noheader
41
42 Does not output element name header record.
43
44
45 -d/--delimit delimiter
46
47 Uses single character or string as the delimiter between ele‐
48 ment names and element values. Default is semicolon.
49
50
51 -e/--extract extract_element
52
53 Specifies the name of the XML element to extract. Elements
54 can be nested in any order, but are output in the order spec‐
55 ified. Elements can be specified multiple times, with a dif‐
56 ferent attribute name or attribute value. An optional attri‐
57 bute (or attribute and value) can also be specified with ele‐
58 ments:
59
60
61
62 • -e element
63
64 • -e element:attrName
65
66 • -e element:attrName:attrValue
67
68
69
70
71
72
73 NOTE:
74
75
76
77 • Elements can be compound values separated by a dot. For
78 example, Switches.Node is a Node element contained within
79 a Switches element.
80
81 • To output the attribute value as opposed to the element
82 value, a specification such as -e NICs.Node:id can be
83 used. This will return the value of the id attribute of
84 any Node elements within NICs element.
85
86 • If desired, a specific element can be selected by its at‐
87 tribute value, such as -e NICs.Node.PortInfo:LinkSpeedAc‐
88 tive:100Gb which will return the value of the PortInfo
89 element within Node element where the PortInfo element
90 has an attribute of LinkSpeedActive with a value of
91 100Gb.
92
93 • A given element can be specified multiple times each with
94 a different AttrName or attrValue.
95
96
97
98
99 -s/--suppress suppress_element
100
101 Specifies the name of the XML element to suppress extraction.
102 Can be used multiple times (in any order). Supports the same
103 syntax as -e.
104
105
106 -X/--infile input_file
107
108 Parses XML from input_file.
109
110
111 -P/--pfile param_file
112
113 Reads command parameters from param_file.
114
115
117 Here is an example of ethreport output filtered by ethxmlextract :
118
119 # ethreport -o comps -x | ethxmlextract -d \; -e NodeDesc -e ChassisID
120 -e NumPorts -s Neighbor
121
122 Getting All Fabric Records...
123
124 Done Getting All Fabric Records
125
126 NodeDesc;ChassisID;NumPorts
127
128 hdarei001;0x0000444ca8e9ddd5;41
129
130 hds1fnc7041-eno1;0x0000a4bf01553c89;1
131
132 hds1fnc7041-eth1;0x0000a4bf01553c89;1
133
134 hds1fnc7061-eth2;0x0000a4bf015540f0;1
135
136 hds1fnc7061-eno1;0x0000a4bf015540f0;1
137
138 hds1fnc7061-eth1;0x0000a4bf015540f0;1
139
140 hds1fnc7081-eth2;0x0000a4bf01554175;1
141
142 hds1fnc7081-eno1;0x0000a4bf01554175;1
143
144 hds1fnc7081-eth1;0x0000a4bf01554175;1
145
146
147
149 ethxmlextract is a flexible and powerful tool to process an XML stream.
150 The tool:
151
152 • Requires no specific element names to be present in the XML.
153
154 • Assumes no hierarchical relationship between elements.
155
156 • Allows extracted element values to be output in any order.
157
158 • Allows an element's value to be extracted only in the context of
159 another specified element.
160
161 • Allows extraction to be suppressed during the scope of specified
162 elements.
163
164 ethxmlextract takes the XML input stream from either stdin or a speci‐
165 fied input file. ethxmlextract does not use or require a connection to
166 a fabric.
167
168 ethxmlextract works from two lists of elements supplied as command line
169 or input parameters. The first is a list of elements whose values are
170 to be extracted, called extraction elements. The second is a list of
171 elements for which extraction is to be suppressed, called suppression
172 elements. When an extraction element is encountered and extraction is
173 not suppressed, the value of the element is extracted for later output
174 in an extraction record. An extraction record contains a value for all
175 extraction elements, including those which have a null value.
176
177 When a suppression element is encountered, then no extraction is per‐
178 formed during the extent of that element, from start through end. Sup‐
179 pression is maintained for elements specified inside the suppression
180 element, including elements which may happen to match extraction ele‐
181 ments. Suppression can be used to prevent extraction in sections of XML
182 that are present, but not of current interest. For example, NodeDesc or
183 IfAddr inside a Neighbor specification of ethreport.
184
185 ethxmlextract attempts to generate extraction records with data values
186 that are valid at the same time. Specifying extraction elements that
187 are valid in the same scope produces a single record for each group of
188 extraction elements. However, mixing extraction elements from different
189 scopes (including different XML levels) may cause ethxmlextract to pro‐
190 duce multiple records.
191
192 ethxmlextract outputs an extraction record under the following condi‐
193 tions:
194
195 • One or more extraction elements containing a non-null value go
196 out of scope (that is, the element containing the extraction el‐
197 ements is ended) and a record containing the element values has
198 not already been output.
199
200 • A new and different value is specified for an extraction element
201 and an extraction record containing the previous value has not
202 already been output.
203
204 Element names (extraction or suppression) can be made context-sensitive
205 with an enclosing element name using the syntax element1.element2. In
206 this case, element2 is extracted (or extraction is suppressed) only
207 when element2 is enclosed by element1.
208
209 The syntax also allows ' * ' to be specified as a wildcard. In this
210 case, *.element3 specifies element3 enclosed by any element or sequence
211 of elements (for example, element1.element3 or element1.element2.ele‐
212 ment3). Similarly, element1.*.element3 specifies element3 enclosed by
213 element1 with any number of (but at least 1) intermediate elements.
214
215 ethxmlextract prepends any entered element name not containing a ' * '
216 (anywhere) with ' *. ', matching the element regardless of the enclos‐
217 ing elements.
218
219 NOTE: Any element names that include a wildcard should be quoted to the
220 shell attempting to wildcard match against filenames.
221
222
223
224 At the beginning of operation, ethxmlextract, by default, outputs a de‐
225 limited header record containing the names of the extraction elements.
226 The order of the names is the same as specified on the command line and
227 is the same order as that of the extraction record. Output of the
228 header record can be disabled with the -H option. By default, element
229 names are shown as they were entered on the command line. The -v option
230 causes element names to be output as they are used during extraction,
231 with any prepended wildcard characters.
232
233 Options (parameters) to ethxmlextract can be specified on the command
234 line, with a parameter file, or using both methods. A parameter file is
235 specified with -P param_file. When a parameter file specification is
236 encountered on the command line, option processing on the command line
237 is suspended, the parameter file is read and processed entirely, and
238 then command line processing is resumed.
239
240 Option syntax within a parameter file is the same as on the command
241 line. Multiple parameter file specifications can be made, on the com‐
242 mand line or within other parameter files. At each point that a parame‐
243 ter file is specified, current option processing is suspended while the
244 parameter file is processed, then resumed. Options are processed in the
245 order they are encountered on the command line or in parameter files. A
246 parameter file can be up to 8192 bytes in size and may contain up to
247 512 parameters.
248
249
250
251Copyright(C) 2020-2022 Intel Corporation ethxmlextract(8)