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">
6 <title>lxml.etree.ElementDepthFirstIterator</title>
7 <link rel="stylesheet" href="epydoc.css" type="text/css" />
8 <script type="text/javascript" src="epydoc.js"></script>
11 <body bgcolor="white" text="black" link="blue" vlink="#204080"
13 <!-- ==================== NAVIGATION BAR ==================== -->
14 <table class="navbar" border="0" width="100%" cellpadding="0"
15 bgcolor="#a0c0ff" cellspacing="0">
18 <th> <a
19 href="lxml-module.html">Home</a> </th>
22 <th> <a
23 href="module-tree.html">Trees</a> </th>
26 <th> <a
27 href="identifier-index.html">Indices</a> </th>
30 <th> <a
31 href="help.html">Help</a> </th>
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>
41 <table width="100%" cellpadding="0" cellspacing="0">
44 <span class="breadcrumbs">
45 <a href="lxml-module.html">Package lxml</a> ::
46 <a href="lxml.etree-module.html">Module etree</a> ::
47 Class ElementDepthFirstIterator
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 private</a>]</span></td></tr>
55 <tr><td align="right"><span class="options"
56 >[<a href="frames.html" target="_top">frames</a
57 >] | <a href="lxml.etree.ElementDepthFirstIterator-class.html"
58 target="_top">no frames</a>]</span></td></tr>
63 <!-- ==================== CLASS DESCRIPTION ==================== -->
64 <h1 class="epydoc">Class ElementDepthFirstIterator</h1><p class="nomargin-top"></p>
65 <pre class="base-tree">
68 <strong class="uidshort">ElementDepthFirstIterator</strong>
72 <p>ElementDepthFirstIterator(self, node, tag=None, inclusive=True)
73 Iterates over an element and its sub-elements in document order (depth
75 <p>Note that this also includes comments, entities and processing
76 instructions. To filter them out, check if the <tt class="rst-docutils literal">tag</tt> property
77 of the returned element is a string (i.e. not None and not a
78 factory function), or pass the <tt class="rst-docutils literal">Element</tt> factory for the <tt class="rst-docutils literal">tag</tt>
79 argument to receive only Elements.</p>
80 <p>If the optional <tt class="rst-docutils literal">tag</tt> argument is not None, the iterator returns only
81 the elements that match the respective name and namespace.</p>
82 <p>The optional boolean argument 'inclusive' defaults to True and can be set
83 to False to exclude the start element itself.</p>
84 <p>Note that the behaviour of this iterator is completely undefined if the
85 tree it traverses is modified during iteration.</p>
87 <!-- ==================== INSTANCE METHODS ==================== -->
88 <a name="section-InstanceMethods"></a>
89 <table class="summary" border="1" cellpadding="3"
90 cellspacing="0" width="100%" bgcolor="white">
91 <tr bgcolor="#70b0f0" class="table-header">
92 <td colspan="2" class="table-header">
93 <table border="0" cellpadding="0" cellspacing="0" width="100%">
95 <td align="left"><span class="table-header">Instance Methods</span></td>
96 <td align="right" valign="top"
97 ><span class="options">[<a href="#section-InstanceMethods"
98 class="privatelink" onclick="toggle_private();"
99 >hide private</a>]</span></td>
105 <td width="15%" align="right" valign="top" class="summary">
106 <span class="summary-type"> </span>
107 </td><td class="summary">
108 <table width="100%" cellpadding="0" cellspacing="0" border="0">
110 <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 />
112 <td align="right" valign="top">
122 <td width="15%" align="right" valign="top" class="summary">
123 <span class="summary-type">a new object with type S, a subtype of T</span>
124 </td><td class="summary">
125 <table width="100%" cellpadding="0" cellspacing="0" border="0">
127 <td><span class="summary-sig"><a href="lxml.etree.ElementDepthFirstIterator-class.html#__new__" class="summary-sig-name">__new__</a>(<span class="summary-sig-arg">T</span>,
128 <span class="summary-sig-arg">S</span>,
129 <span class="summary-sig-arg">...</span>)</span></td>
130 <td align="right" valign="top">
140 <td width="15%" align="right" valign="top" class="summary">
141 <span class="summary-type"> </span>
142 </td><td class="summary">
143 <table width="100%" cellpadding="0" cellspacing="0" border="0">
145 <td><span class="summary-sig"><a name="__next__"></a><span class="summary-sig-name">__next__</span>(<span class="summary-sig-arg">...</span>)</span></td>
146 <td align="right" valign="top">
156 <td width="15%" align="right" valign="top" class="summary">
157 <span class="summary-type">the next value, or raise StopIteration</span>
158 </td><td class="summary">
159 <table width="100%" cellpadding="0" cellspacing="0" border="0">
161 <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>
162 <td align="right" valign="top">
172 <td colspan="2" class="summary">
173 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
174 <code>__delattr__</code>,
175 <code>__format__</code>,
176 <code>__getattribute__</code>,
177 <code>__hash__</code>,
178 <code>__init__</code>,
179 <code>__reduce__</code>,
180 <code>__reduce_ex__</code>,
181 <code>__repr__</code>,
182 <code>__setattr__</code>,
183 <code>__sizeof__</code>,
184 <code>__str__</code>,
185 <code>__subclasshook__</code>
190 <!-- ==================== PROPERTIES ==================== -->
191 <a name="section-Properties"></a>
192 <table class="summary" border="1" cellpadding="3"
193 cellspacing="0" width="100%" bgcolor="white">
194 <tr bgcolor="#70b0f0" class="table-header">
195 <td colspan="2" class="table-header">
196 <table border="0" cellpadding="0" cellspacing="0" width="100%">
198 <td align="left"><span class="table-header">Properties</span></td>
199 <td align="right" valign="top"
200 ><span class="options">[<a href="#section-Properties"
201 class="privatelink" onclick="toggle_private();"
202 >hide private</a>]</span></td>
208 <td colspan="2" class="summary">
209 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
210 <code>__class__</code>
215 <!-- ==================== METHOD DETAILS ==================== -->
216 <a name="section-MethodDetails"></a>
217 <table class="details" border="1" cellpadding="3"
218 cellspacing="0" width="100%" bgcolor="white">
219 <tr bgcolor="#70b0f0" class="table-header">
220 <td colspan="2" class="table-header">
221 <table border="0" cellpadding="0" cellspacing="0" width="100%">
223 <td align="left"><span class="table-header">Method Details</span></td>
224 <td align="right" valign="top"
225 ><span class="options">[<a href="#section-MethodDetails"
226 class="privatelink" onclick="toggle_private();"
227 >hide private</a>]</span></td>
233 <a name="__new__"></a>
235 <table class="details" border="1" cellpadding="3"
236 cellspacing="0" width="100%" bgcolor="white">
238 <table width="100%" cellpadding="0" cellspacing="0" border="0">
239 <tr valign="top"><td>
240 <h3 class="epydoc"><span class="sig"><span class="sig-name">__new__</span>(<span class="sig-arg">T</span>,
241 <span class="sig-arg">S</span>,
242 <span class="sig-arg">...</span>)</span>
244 </td><td align="right" valign="top"
251 <dt>Returns: a new object with type S, a subtype of T</dt>
259 <!-- ==================== NAVIGATION BAR ==================== -->
260 <table class="navbar" border="0" width="100%" cellpadding="0"
261 bgcolor="#a0c0ff" cellspacing="0">
264 <th> <a
265 href="lxml-module.html">Home</a> </th>
268 <th> <a
269 href="module-tree.html">Trees</a> </th>
272 <th> <a
273 href="identifier-index.html">Indices</a> </th>
276 <th> <a
277 href="help.html">Help</a> </th>
279 <!-- Project homepage -->
280 <th class="navbar" align="right" width="100%">
281 <table border="0" cellpadding="0" cellspacing="0">
282 <tr><th class="navbar" align="center"
283 ><a class="navbar" target="_top" href="/">lxml API</a></th>
287 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
289 <td align="left" class="footer">
290 Generated by Epydoc 3.0.1
291 on Wed Jan 29 12:26:21 2020
293 <td align="right" class="footer">
294 <a target="mainFrame" href="http://epydoc.sourceforge.net"
295 >http://epydoc.sourceforge.net</a>
300 <script type="text/javascript">
302 // Private objects are initially displayed (because if
303 // javascript is turned off then we want them to be
304 // visible); but by default, we want to hide them. So hide
305 // them unless we have a cookie that says to show them.