Imported Upstream version 4.5.2
[platform/upstream/python-lxml.git] / doc / html / api / lxml.etree.iterparse-class.html
1 <?xml version="1.0" encoding="ascii"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3           "DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6   <title>lxml.etree.iterparse</title>
7   <link rel="stylesheet" href="epydoc.css" type="text/css" />
8   <script type="text/javascript" src="epydoc.js"></script>
9 </head>
10
11 <body bgcolor="white" text="black" link="blue" vlink="#204080"
12       alink="#204080">
13 <!-- ==================== NAVIGATION BAR ==================== -->
14 <table class="navbar" border="0" width="100%" cellpadding="0"
15        bgcolor="#a0c0ff" cellspacing="0">
16   <tr valign="middle">
17   <!-- Home link -->
18       <th>&nbsp;&nbsp;&nbsp;<a
19         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21   <!-- Tree link -->
22       <th>&nbsp;&nbsp;&nbsp;<a
23         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25   <!-- Index link -->
26       <th>&nbsp;&nbsp;&nbsp;<a
27         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29   <!-- Help link -->
30       <th>&nbsp;&nbsp;&nbsp;<a
31         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33   <!-- Project homepage -->
34       <th class="navbar" align="right" width="100%">
35         <table border="0" cellpadding="0" cellspacing="0">
36           <tr><th class="navbar" align="center"
37             ><a class="navbar" target="_top" href="/">lxml API</a></th>
38           </tr></table></th>
39   </tr>
40 </table>
41 <table width="100%" cellpadding="0" cellspacing="0">
42   <tr valign="top">
43     <td width="100%">
44       <span class="breadcrumbs">
45         <a href="lxml-module.html">Package&nbsp;lxml</a> ::
46         <a href="lxml.etree-module.html">Module&nbsp;etree</a> ::
47         Class&nbsp;iterparse
48       </span>
49     </td>
50     <td>
51       <table cellpadding="0" cellspacing="0">
52         <!-- hide/show private -->
53         <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
54     onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
55         <tr><td align="right"><span class="options"
56             >[<a href="frames.html" target="_top">frames</a
57             >]&nbsp;|&nbsp;<a href="lxml.etree.iterparse-class.html"
58             target="_top">no&nbsp;frames</a>]</span></td></tr>
59       </table>
60     </td>
61   </tr>
62 </table>
63 <!-- ==================== CLASS DESCRIPTION ==================== -->
64 <h1 class="epydoc">Class iterparse</h1><p class="nomargin-top"></p>
65 <pre class="base-tree">
66 object --+
67          |
68         <strong class="uidshort">iterparse</strong>
69 </pre>
70
71 <hr />
72 <p>iterparse(self, source, events=(&quot;end&quot;,), tag=None,                   attribute_defaults=False, dtd_validation=False,                   load_dtd=False, no_network=True, remove_blank_text=False,                   remove_comments=False, remove_pis=False, encoding=None,                   html=False, recover=None, huge_tree=False, schema=None)</p>
73 <p>Incremental parser.</p>
74 <p>Parses XML into a tree and generates tuples (event, element) in a
75 SAX-like fashion. <tt class="rst-docutils literal">event</tt> is any of 'start', 'end', 'start-ns',
76 'end-ns'.</p>
77 <p>For 'start' and 'end', <tt class="rst-docutils literal">element</tt> is the Element that the parser just
78 found opening or closing.  For 'start-ns', it is a tuple (prefix, URI) of
79 a new namespace declaration.  For 'end-ns', it is simply None.  Note that
80 all start and end events are guaranteed to be properly nested.</p>
81 <p>The keyword argument <tt class="rst-docutils literal">events</tt> specifies a sequence of event type names
82 that should be generated.  By default, only 'end' events will be
83 generated.</p>
84 <p>The additional <tt class="rst-docutils literal">tag</tt> argument restricts the 'start' and 'end' events to
85 those elements that match the given tag.  The <tt class="rst-docutils literal">tag</tt> argument can also be
86 a sequence of tags to allow matching more than one tag.  By default,
87 events are generated for all elements.  Note that the 'start-ns' and
88 'end-ns' events are not impacted by this restriction.</p>
89 <p>The other keyword arguments in the constructor are mainly based on the
90 libxml2 parser configuration.  A DTD will also be loaded if validation or
91 attribute default values are requested.</p>
92 <dl class="rst-docutils">
93 <dt>Available boolean keyword arguments:</dt>
94 <dd><ul class="rst-first rst-last rst-simple">
95 <li>attribute_defaults: read default attributes from DTD</li>
96 <li>dtd_validation: validate (if DTD is available)</li>
97 <li>load_dtd: use DTD for parsing</li>
98 <li>no_network: prevent network access for related files</li>
99 <li>remove_blank_text: discard blank text nodes</li>
100 <li>remove_comments: discard comments</li>
101 <li>remove_pis: discard processing instructions</li>
102 <li>strip_cdata: replace CDATA sections by normal text content (default: True)</li>
103 <li>compact: safe memory for short text content (default: True)</li>
104 <li>resolve_entities: replace entities by their text value (default: True)</li>
105 <li><dl class="rst-first rst-docutils">
106 <dt>huge_tree: disable security restrictions and support very deep trees</dt>
107 <dd>and very long text content (only affects libxml2 2.7+)</dd>
108 </dl>
109 </li>
110 <li>html: parse input as HTML (default: XML)</li>
111 <li><dl class="rst-first rst-docutils">
112 <dt>recover: try hard to parse through broken input (default: True for HTML,</dt>
113 <dd>False otherwise)</dd>
114 </dl>
115 </li>
116 </ul>
117 </dd>
118 <dt>Other keyword arguments:</dt>
119 <dd><ul class="rst-first rst-last rst-simple">
120 <li>encoding: override the document encoding</li>
121 <li>schema: an XMLSchema to validate against</li>
122 </ul>
123 </dd>
124 </dl>
125
126 <!-- ==================== INSTANCE METHODS ==================== -->
127 <a name="section-InstanceMethods"></a>
128 <table class="summary" border="1" cellpadding="3"
129        cellspacing="0" width="100%" bgcolor="white">
130 <tr bgcolor="#70b0f0" class="table-header">
131   <td colspan="2" class="table-header">
132     <table border="0" cellpadding="0" cellspacing="0" width="100%">
133       <tr valign="top">
134         <td align="left"><span class="table-header">Instance Methods</span></td>
135         <td align="right" valign="top"
136          ><span class="options">[<a href="#section-InstanceMethods"
137          class="privatelink" onclick="toggle_private();"
138          >hide private</a>]</span></td>
139       </tr>
140     </table>
141   </td>
142 </tr>
143 <tr>
144     <td width="15%" align="right" valign="top" class="summary">
145       <span class="summary-type">&nbsp;</span>
146     </td><td class="summary">
147       <table width="100%" cellpadding="0" cellspacing="0" border="0">
148         <tr>
149           <td><span class="summary-sig"><a href="lxml.etree.iterparse-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
150         <span class="summary-sig-arg">source</span>,
151         <span class="summary-sig-arg">events</span>=<span class="summary-sig-default">(&quot;end&quot;</span>,
152         <span class="summary-sig-arg">)</span>,
153         <span class="summary-sig-arg">tag</span>=<span class="summary-sig-default">None</span>,
154         <span class="summary-sig-arg">attribute_defaults</span>=<span class="summary-sig-default">False</span>,
155         <span class="summary-sig-arg">dtd_validation</span>=<span class="summary-sig-default">False</span>,
156         <span class="summary-sig-arg">load_dtd</span>=<span class="summary-sig-default">False</span>,
157         <span class="summary-sig-arg">no_network</span>=<span class="summary-sig-default">True</span>,
158         <span class="summary-sig-arg">remove_blank_text</span>=<span class="summary-sig-default">False</span>,
159         <span class="summary-sig-arg">remove_comments</span>=<span class="summary-sig-default">False</span>,
160         <span class="summary-sig-arg">remove_pis</span>=<span class="summary-sig-default">False</span>,
161         <span class="summary-sig-arg">encoding</span>=<span class="summary-sig-default">None</span>,
162         <span class="summary-sig-arg">html</span>=<span class="summary-sig-default">False</span>,
163         <span class="summary-sig-arg">recover</span>=<span class="summary-sig-default">None</span>,
164         <span class="summary-sig-arg">huge_tree</span>=<span class="summary-sig-default">False</span>,
165         <span class="summary-sig-arg">schema</span>=<span class="summary-sig-default">None</span>)</span><br />
166       x.__init__(...) initializes x; see help(type(x)) for signature</td>
167           <td align="right" valign="top">
168             
169             
170           </td>
171         </tr>
172       </table>
173       
174     </td>
175   </tr>
176 <tr>
177     <td width="15%" align="right" valign="top" class="summary">
178       <span class="summary-type">&nbsp;</span>
179     </td><td class="summary">
180       <table width="100%" cellpadding="0" cellspacing="0" border="0">
181         <tr>
182           <td><span class="summary-sig"><a name="__iter__"></a><span class="summary-sig-name">__iter__</span>(<span class="summary-sig-arg">x</span>)</span><br />
183       iter(x)</td>
184           <td align="right" valign="top">
185             
186             
187           </td>
188         </tr>
189       </table>
190       
191     </td>
192   </tr>
193 <tr>
194     <td width="15%" align="right" valign="top" class="summary">
195       <span class="summary-type">a new object with type S, a subtype of T</span>
196     </td><td class="summary">
197       <table width="100%" cellpadding="0" cellspacing="0" border="0">
198         <tr>
199           <td><span class="summary-sig"><a href="lxml.etree.iterparse-class.html#__new__" class="summary-sig-name">__new__</a>(<span class="summary-sig-arg">T</span>,
200         <span class="summary-sig-arg">S</span>,
201         <span class="summary-sig-arg">...</span>)</span></td>
202           <td align="right" valign="top">
203             
204             
205           </td>
206         </tr>
207       </table>
208       
209     </td>
210   </tr>
211 <tr>
212     <td width="15%" align="right" valign="top" class="summary">
213       <span class="summary-type">&nbsp;</span>
214     </td><td class="summary">
215       <table width="100%" cellpadding="0" cellspacing="0" border="0">
216         <tr>
217           <td><span class="summary-sig"><a name="__next__"></a><span class="summary-sig-name">__next__</span>(<span class="summary-sig-arg">...</span>)</span></td>
218           <td align="right" valign="top">
219             
220             
221           </td>
222         </tr>
223       </table>
224       
225     </td>
226   </tr>
227 <tr>
228     <td width="15%" align="right" valign="top" class="summary">
229       <span class="summary-type">&nbsp;</span>
230     </td><td class="summary">
231       <table width="100%" cellpadding="0" cellspacing="0" border="0">
232         <tr>
233           <td><span class="summary-sig"><a name="makeelement"></a><span class="summary-sig-name">makeelement</span>(<span class="summary-sig-arg">self</span>,
234         <span class="summary-sig-arg">_tag</span>,
235         <span class="summary-sig-arg">attrib</span>=<span class="summary-sig-default">None</span>,
236         <span class="summary-sig-arg">nsmap</span>=<span class="summary-sig-default">None</span>,
237         <span class="summary-sig-arg">**_extra</span>)</span><br />
238       Creates a new element associated with this parser.</td>
239           <td align="right" valign="top">
240             
241             
242           </td>
243         </tr>
244       </table>
245       
246     </td>
247   </tr>
248 <tr>
249     <td width="15%" align="right" valign="top" class="summary">
250       <span class="summary-type">the next value, or raise StopIteration</span>
251     </td><td class="summary">
252       <table width="100%" cellpadding="0" cellspacing="0" border="0">
253         <tr>
254           <td><span class="summary-sig"><a name="next"></a><span class="summary-sig-name">next</span>(<span class="summary-sig-arg">x</span>)</span></td>
255           <td align="right" valign="top">
256             
257             
258           </td>
259         </tr>
260       </table>
261       
262     </td>
263   </tr>
264 <tr>
265     <td width="15%" align="right" valign="top" class="summary">
266       <span class="summary-type">&nbsp;</span>
267     </td><td class="summary">
268       <table width="100%" cellpadding="0" cellspacing="0" border="0">
269         <tr>
270           <td><span class="summary-sig"><a href="lxml.etree.iterparse-class.html#set_element_class_lookup" class="summary-sig-name">set_element_class_lookup</a>(<span class="summary-sig-arg">self</span>,
271         <span class="summary-sig-arg">lookup</span>=<span class="summary-sig-default"> None</span>)</span><br />
272       Set a lookup scheme for element classes generated from this parser.</td>
273           <td align="right" valign="top">
274             
275             
276           </td>
277         </tr>
278       </table>
279       
280     </td>
281   </tr>
282   <tr>
283     <td colspan="2" class="summary">
284     <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
285       <code>__delattr__</code>,
286       <code>__format__</code>,
287       <code>__getattribute__</code>,
288       <code>__hash__</code>,
289       <code>__reduce__</code>,
290       <code>__reduce_ex__</code>,
291       <code>__repr__</code>,
292       <code>__setattr__</code>,
293       <code>__sizeof__</code>,
294       <code>__str__</code>,
295       <code>__subclasshook__</code>
296       </p>
297     </td>
298   </tr>
299 </table>
300 <!-- ==================== PROPERTIES ==================== -->
301 <a name="section-Properties"></a>
302 <table class="summary" border="1" cellpadding="3"
303        cellspacing="0" width="100%" bgcolor="white">
304 <tr bgcolor="#70b0f0" class="table-header">
305   <td colspan="2" class="table-header">
306     <table border="0" cellpadding="0" cellspacing="0" width="100%">
307       <tr valign="top">
308         <td align="left"><span class="table-header">Properties</span></td>
309         <td align="right" valign="top"
310          ><span class="options">[<a href="#section-Properties"
311          class="privatelink" onclick="toggle_private();"
312          >hide private</a>]</span></td>
313       </tr>
314     </table>
315   </td>
316 </tr>
317 <tr>
318     <td width="15%" align="right" valign="top" class="summary">
319       <span class="summary-type">&nbsp;</span>
320     </td><td class="summary">
321         <a name="error_log"></a><span class="summary-name">error_log</span><br />
322       The error log of the last (or current) parser run.
323     </td>
324   </tr>
325 <tr>
326     <td width="15%" align="right" valign="top" class="summary">
327       <span class="summary-type">&nbsp;</span>
328     </td><td class="summary">
329         <a name="resolvers"></a><span class="summary-name">resolvers</span><br />
330       The custom resolver registry of the last (or current) parser run.
331     </td>
332   </tr>
333 <tr>
334     <td width="15%" align="right" valign="top" class="summary">
335       <span class="summary-type">&nbsp;</span>
336     </td><td class="summary">
337         <a name="root"></a><span class="summary-name">root</span>
338     </td>
339   </tr>
340 <tr>
341     <td width="15%" align="right" valign="top" class="summary">
342       <span class="summary-type">&nbsp;</span>
343     </td><td class="summary">
344         <a name="version"></a><span class="summary-name">version</span><br />
345       The version of the underlying XML parser.
346     </td>
347   </tr>
348   <tr>
349     <td colspan="2" class="summary">
350     <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
351       <code>__class__</code>
352       </p>
353     </td>
354   </tr>
355 </table>
356 <!-- ==================== METHOD DETAILS ==================== -->
357 <a name="section-MethodDetails"></a>
358 <table class="details" border="1" cellpadding="3"
359        cellspacing="0" width="100%" bgcolor="white">
360 <tr bgcolor="#70b0f0" class="table-header">
361   <td colspan="2" class="table-header">
362     <table border="0" cellpadding="0" cellspacing="0" width="100%">
363       <tr valign="top">
364         <td align="left"><span class="table-header">Method Details</span></td>
365         <td align="right" valign="top"
366          ><span class="options">[<a href="#section-MethodDetails"
367          class="privatelink" onclick="toggle_private();"
368          >hide private</a>]</span></td>
369       </tr>
370     </table>
371   </td>
372 </tr>
373 </table>
374 <a name="__init__"></a>
375 <div>
376 <table class="details" border="1" cellpadding="3"
377        cellspacing="0" width="100%" bgcolor="white">
378 <tr><td>
379   <table width="100%" cellpadding="0" cellspacing="0" border="0">
380   <tr valign="top"><td>
381   <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
382         <span class="sig-arg">source</span>,
383         <span class="sig-arg">events</span>=<span class="sig-default">(&quot;end&quot;</span>,
384         <span class="sig-arg">)</span>,
385         <span class="sig-arg">tag</span>=<span class="sig-default">None</span>,
386         <span class="sig-arg">attribute_defaults</span>=<span class="sig-default">False</span>,
387         <span class="sig-arg">dtd_validation</span>=<span class="sig-default">False</span>,
388         <span class="sig-arg">load_dtd</span>=<span class="sig-default">False</span>,
389         <span class="sig-arg">no_network</span>=<span class="sig-default">True</span>,
390         <span class="sig-arg">remove_blank_text</span>=<span class="sig-default">False</span>,
391         <span class="sig-arg">remove_comments</span>=<span class="sig-default">False</span>,
392         <span class="sig-arg">remove_pis</span>=<span class="sig-default">False</span>,
393         <span class="sig-arg">encoding</span>=<span class="sig-default">None</span>,
394         <span class="sig-arg">html</span>=<span class="sig-default">False</span>,
395         <span class="sig-arg">recover</span>=<span class="sig-default">None</span>,
396         <span class="sig-arg">huge_tree</span>=<span class="sig-default">False</span>,
397         <span class="sig-arg">schema</span>=<span class="sig-default">None</span>)</span>
398     <br /><em class="fname">(Constructor)</em>
399   </h3>
400   </td><td align="right" valign="top"
401     >&nbsp;
402     </td>
403   </tr></table>
404   
405   x.__init__(...) initializes x; see help(type(x)) for signature
406   <dl class="fields">
407     <dt>Overrides:
408         object.__init__
409     </dt>
410   </dl>
411 </td></tr></table>
412 </div>
413 <a name="__new__"></a>
414 <div>
415 <table class="details" border="1" cellpadding="3"
416        cellspacing="0" width="100%" bgcolor="white">
417 <tr><td>
418   <table width="100%" cellpadding="0" cellspacing="0" border="0">
419   <tr valign="top"><td>
420   <h3 class="epydoc"><span class="sig"><span class="sig-name">__new__</span>(<span class="sig-arg">T</span>,
421         <span class="sig-arg">S</span>,
422         <span class="sig-arg">...</span>)</span>
423   </h3>
424   </td><td align="right" valign="top"
425     >&nbsp;
426     </td>
427   </tr></table>
428   
429   
430   <dl class="fields">
431     <dt>Returns: a new object with type S, a subtype of T</dt>
432     <dt>Overrides:
433         object.__new__
434     </dt>
435   </dl>
436 </td></tr></table>
437 </div>
438 <a name="set_element_class_lookup"></a>
439 <div>
440 <table class="details" border="1" cellpadding="3"
441        cellspacing="0" width="100%" bgcolor="white">
442 <tr><td>
443   <table width="100%" cellpadding="0" cellspacing="0" border="0">
444   <tr valign="top"><td>
445   <h3 class="epydoc"><span class="sig"><span class="sig-name">set_element_class_lookup</span>(<span class="sig-arg">self</span>,
446         <span class="sig-arg">lookup</span>=<span class="sig-default"> None</span>)</span>
447   </h3>
448   </td><td align="right" valign="top"
449     >&nbsp;
450     </td>
451   </tr></table>
452   
453   <p>Set a lookup scheme for element classes generated from this parser.</p>
454 <p>Reset it by passing None or nothing.</p>
455   <dl class="fields">
456   </dl>
457 </td></tr></table>
458 </div>
459 <br />
460 <!-- ==================== NAVIGATION BAR ==================== -->
461 <table class="navbar" border="0" width="100%" cellpadding="0"
462        bgcolor="#a0c0ff" cellspacing="0">
463   <tr valign="middle">
464   <!-- Home link -->
465       <th>&nbsp;&nbsp;&nbsp;<a
466         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
467
468   <!-- Tree link -->
469       <th>&nbsp;&nbsp;&nbsp;<a
470         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
471
472   <!-- Index link -->
473       <th>&nbsp;&nbsp;&nbsp;<a
474         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
475
476   <!-- Help link -->
477       <th>&nbsp;&nbsp;&nbsp;<a
478         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
479
480   <!-- Project homepage -->
481       <th class="navbar" align="right" width="100%">
482         <table border="0" cellpadding="0" cellspacing="0">
483           <tr><th class="navbar" align="center"
484             ><a class="navbar" target="_top" href="/">lxml API</a></th>
485           </tr></table></th>
486   </tr>
487 </table>
488 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
489   <tr>
490     <td align="left" class="footer">
491     Generated by Epydoc 3.0.1
492     on Thu Jul  9 18:29:53 2020
493     </td>
494     <td align="right" class="footer">
495       <a target="mainFrame" href="http://epydoc.sourceforge.net"
496         >http://epydoc.sourceforge.net</a>
497     </td>
498   </tr>
499 </table>
500
501 <script type="text/javascript">
502   <!--
503   // Private objects are initially displayed (because if
504   // javascript is turned off then we want them to be
505   // visible); but by default, we want to hide them.  So hide
506   // them unless we have a cookie that says to show them.
507   checkCookie();
508   // -->
509 </script>
510 </body>
511 </html>