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._ElementTree</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 _ElementTree
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._ElementTree-class.html"
58 target="_top">no frames</a>]</span></td></tr>
63 <!-- ==================== CLASS DESCRIPTION ==================== -->
64 <h1 class="epydoc">Class _ElementTree</h1><p class="nomargin-top"></p>
65 <pre class="base-tree">
68 <strong class="uidshort">_ElementTree</strong>
71 <dl><dt>Known Subclasses:</dt>
73 <ul class="subclass-list">
74 <li class="private"><a href="lxml.etree._XSLTResultTree-class.html" onclick="show_private();">_XSLTResultTree</a></li> </ul>
78 <!-- ==================== INSTANCE METHODS ==================== -->
79 <a name="section-InstanceMethods"></a>
80 <table class="summary" border="1" cellpadding="3"
81 cellspacing="0" width="100%" bgcolor="white">
82 <tr bgcolor="#70b0f0" class="table-header">
83 <td colspan="2" class="table-header">
84 <table border="0" cellpadding="0" cellspacing="0" width="100%">
86 <td align="left"><span class="table-header">Instance Methods</span></td>
87 <td align="right" valign="top"
88 ><span class="options">[<a href="#section-InstanceMethods"
89 class="privatelink" onclick="toggle_private();"
90 >hide private</a>]</span></td>
96 <td width="15%" align="right" valign="top" class="summary">
97 <span class="summary-type"> </span>
98 </td><td class="summary">
99 <table width="100%" cellpadding="0" cellspacing="0" border="0">
101 <td><span class="summary-sig"><a name="__copy__"></a><span class="summary-sig-name">__copy__</span>(<span class="summary-sig-arg">...</span>)</span></td>
102 <td align="right" valign="top">
112 <td width="15%" align="right" valign="top" class="summary">
113 <span class="summary-type"> </span>
114 </td><td class="summary">
115 <table width="100%" cellpadding="0" cellspacing="0" border="0">
117 <td><span class="summary-sig"><a name="__deepcopy__"></a><span class="summary-sig-name">__deepcopy__</span>(<span class="summary-sig-arg">...</span>)</span></td>
118 <td align="right" valign="top">
128 <td width="15%" align="right" valign="top" class="summary">
129 <span class="summary-type">a new object with type S, a subtype of T</span>
130 </td><td class="summary">
131 <table width="100%" cellpadding="0" cellspacing="0" border="0">
133 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#__new__" class="summary-sig-name">__new__</a>(<span class="summary-sig-arg">T</span>,
134 <span class="summary-sig-arg">S</span>,
135 <span class="summary-sig-arg">...</span>)</span></td>
136 <td align="right" valign="top">
146 <td width="15%" align="right" valign="top" class="summary">
147 <span class="summary-type"> </span>
148 </td><td class="summary">
149 <table width="100%" cellpadding="0" cellspacing="0" border="0">
151 <td><span class="summary-sig"><a name="_setroot"></a><span class="summary-sig-name">_setroot</span>(<span class="summary-sig-arg">self</span>,
152 <span class="summary-sig-arg">root</span>)</span><br />
153 Relocate the ElementTree to a new root node.</td>
154 <td align="right" valign="top">
164 <td width="15%" align="right" valign="top" class="summary">
165 <span class="summary-type"> </span>
166 </td><td class="summary">
167 <table width="100%" cellpadding="0" cellspacing="0" border="0">
169 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#find" class="summary-sig-name">find</a>(<span class="summary-sig-arg">self</span>,
170 <span class="summary-sig-arg">path</span>,
171 <span class="summary-sig-arg">namespaces</span>=<span class="summary-sig-default">None</span>)</span><br />
172 Finds the first toplevel element with given tag. Same as
173 <tt class="rst-docutils literal"><span class="pre">tree.getroot().find(path)</span></tt>.</td>
174 <td align="right" valign="top">
184 <td width="15%" align="right" valign="top" class="summary">
185 <span class="summary-type"> </span>
186 </td><td class="summary">
187 <table width="100%" cellpadding="0" cellspacing="0" border="0">
189 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#findall" class="summary-sig-name">findall</a>(<span class="summary-sig-arg">self</span>,
190 <span class="summary-sig-arg">path</span>,
191 <span class="summary-sig-arg">namespaces</span>=<span class="summary-sig-default">None</span>)</span><br />
192 Finds all elements matching the ElementPath expression. Same as
193 getroot().findall(path).</td>
194 <td align="right" valign="top">
204 <td width="15%" align="right" valign="top" class="summary">
205 <span class="summary-type"> </span>
206 </td><td class="summary">
207 <table width="100%" cellpadding="0" cellspacing="0" border="0">
209 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#findtext" class="summary-sig-name">findtext</a>(<span class="summary-sig-arg">self</span>,
210 <span class="summary-sig-arg">path</span>,
211 <span class="summary-sig-arg">default</span>=<span class="summary-sig-default">None</span>,
212 <span class="summary-sig-arg">namespaces</span>=<span class="summary-sig-default">None</span>)</span><br />
213 Finds the text for the first element matching the ElementPath
214 expression. Same as getroot().findtext(path)</td>
215 <td align="right" valign="top">
225 <td width="15%" align="right" valign="top" class="summary">
226 <span class="summary-type"> </span>
227 </td><td class="summary">
228 <table width="100%" cellpadding="0" cellspacing="0" border="0">
230 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#getiterator" class="summary-sig-name">getiterator</a>(<span class="summary-sig-arg">self</span>,
231 <span class="summary-sig-arg">tag</span>=<span class="summary-sig-default">None</span>)</span><br />
232 Returns a sequence or iterator of all elements in document order
233 (depth first pre-order), starting with the root element.</td>
234 <td align="right" valign="top">
244 <td width="15%" align="right" valign="top" class="summary">
245 <span class="summary-type"> </span>
246 </td><td class="summary">
247 <table width="100%" cellpadding="0" cellspacing="0" border="0">
249 <td><span class="summary-sig"><a name="getpath"></a><span class="summary-sig-name">getpath</span>(<span class="summary-sig-arg">self</span>,
250 <span class="summary-sig-arg">element</span>)</span><br />
251 Returns a structural, absolute XPath expression to find that element.</td>
252 <td align="right" valign="top">
262 <td width="15%" align="right" valign="top" class="summary">
263 <span class="summary-type"> </span>
264 </td><td class="summary">
265 <table width="100%" cellpadding="0" cellspacing="0" border="0">
267 <td><span class="summary-sig"><a name="getroot"></a><span class="summary-sig-name">getroot</span>(<span class="summary-sig-arg">self</span>)</span><br />
268 Gets the root element for this tree.</td>
269 <td align="right" valign="top">
279 <td width="15%" align="right" valign="top" class="summary">
280 <span class="summary-type"> </span>
281 </td><td class="summary">
282 <table width="100%" cellpadding="0" cellspacing="0" border="0">
284 <td><span class="summary-sig"><a name="iter"></a><span class="summary-sig-name">iter</span>(<span class="summary-sig-arg">self</span>,
285 <span class="summary-sig-arg">tag</span>=<span class="summary-sig-default">None</span>)</span><br />
286 Creates an iterator for the root element. The iterator loops over
287 all elements in this tree, in document order.</td>
288 <td align="right" valign="top">
298 <td width="15%" align="right" valign="top" class="summary">
299 <span class="summary-type"> </span>
300 </td><td class="summary">
301 <table width="100%" cellpadding="0" cellspacing="0" border="0">
303 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#iterfind" class="summary-sig-name">iterfind</a>(<span class="summary-sig-arg">self</span>,
304 <span class="summary-sig-arg">path</span>,
305 <span class="summary-sig-arg">namespaces</span>=<span class="summary-sig-default">None</span>)</span><br />
306 Iterates over all elements matching the ElementPath expression.
307 Same as getroot().iterfind(path).</td>
308 <td align="right" valign="top">
318 <td width="15%" align="right" valign="top" class="summary">
319 <span class="summary-type"> </span>
320 </td><td class="summary">
321 <table width="100%" cellpadding="0" cellspacing="0" border="0">
323 <td><span class="summary-sig"><a name="parse"></a><span class="summary-sig-name">parse</span>(<span class="summary-sig-arg">self</span>,
324 <span class="summary-sig-arg">source</span>,
325 <span class="summary-sig-arg">parser</span>=<span class="summary-sig-default">None</span>,
326 <span class="summary-sig-arg">base_url</span>=<span class="summary-sig-default">None</span>)</span><br />
327 Updates self with the content of source and returns its root</td>
328 <td align="right" valign="top">
338 <td width="15%" align="right" valign="top" class="summary">
339 <span class="summary-type"> </span>
340 </td><td class="summary">
341 <table width="100%" cellpadding="0" cellspacing="0" border="0">
343 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#relaxng" class="summary-sig-name">relaxng</a>(<span class="summary-sig-arg">self</span>,
344 <span class="summary-sig-arg">relaxng</span>)</span><br />
345 Validate this document using other document.</td>
346 <td align="right" valign="top">
356 <td width="15%" align="right" valign="top" class="summary">
357 <span class="summary-type"> </span>
358 </td><td class="summary">
359 <table width="100%" cellpadding="0" cellspacing="0" border="0">
361 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#write" class="summary-sig-name">write</a>(<span class="summary-sig-arg">self</span>,
362 <span class="summary-sig-arg">file</span>,
363 <span class="summary-sig-arg">encoding</span>=<span class="summary-sig-default">None</span>,
364 <span class="summary-sig-arg">method</span>=<span class="summary-sig-default">"xml"</span>,
365 <span class="summary-sig-arg">pretty_print</span>=<span class="summary-sig-default">False</span>,
366 <span class="summary-sig-arg">xml_declaration</span>=<span class="summary-sig-default">None</span>,
367 <span class="summary-sig-arg">with_tail</span>=<span class="summary-sig-default">True</span>,
368 <span class="summary-sig-arg">standalone</span>=<span class="summary-sig-default">None</span>,
369 <span class="summary-sig-arg">compression</span>=<span class="summary-sig-default">0</span>,
370 <span class="summary-sig-arg">exclusive</span>=<span class="summary-sig-default">False</span>,
371 <span class="summary-sig-arg">with_comments</span>=<span class="summary-sig-default">True</span>)</span><br />
372 Write the tree to a filename, file or file-like object.</td>
373 <td align="right" valign="top">
383 <td width="15%" align="right" valign="top" class="summary">
384 <span class="summary-type"> </span>
385 </td><td class="summary">
386 <table width="100%" cellpadding="0" cellspacing="0" border="0">
388 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#write_c14n" class="summary-sig-name">write_c14n</a>(<span class="summary-sig-arg">self</span>,
389 <span class="summary-sig-arg">file</span>,
390 <span class="summary-sig-arg">exclusive</span>=<span class="summary-sig-default">False</span>,
391 <span class="summary-sig-arg">with_comments</span>=<span class="summary-sig-default">True</span>,
392 <span class="summary-sig-arg">compression</span>=<span class="summary-sig-default">0</span>)</span><br />
393 C14N write of document. Always writes UTF-8.</td>
394 <td align="right" valign="top">
404 <td width="15%" align="right" valign="top" class="summary">
405 <span class="summary-type"> </span>
406 </td><td class="summary">
407 <table width="100%" cellpadding="0" cellspacing="0" border="0">
409 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#xinclude" class="summary-sig-name">xinclude</a>(<span class="summary-sig-arg">self</span>)</span><br />
410 Process the XInclude nodes in this document and include the
411 referenced XML fragments.</td>
412 <td align="right" valign="top">
422 <td width="15%" align="right" valign="top" class="summary">
423 <span class="summary-type"> </span>
424 </td><td class="summary">
425 <table width="100%" cellpadding="0" cellspacing="0" border="0">
427 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#xmlschema" class="summary-sig-name">xmlschema</a>(<span class="summary-sig-arg">self</span>,
428 <span class="summary-sig-arg">xmlschema</span>)</span><br />
429 Validate this document using other document.</td>
430 <td align="right" valign="top">
440 <td width="15%" align="right" valign="top" class="summary">
441 <span class="summary-type"> </span>
442 </td><td class="summary">
443 <table width="100%" cellpadding="0" cellspacing="0" border="0">
445 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#xpath" class="summary-sig-name">xpath</a>(<span class="summary-sig-arg">self</span>,
446 <span class="summary-sig-arg">_path</span>,
447 <span class="summary-sig-arg">namespaces</span>=<span class="summary-sig-default">None</span>,
448 <span class="summary-sig-arg">extensions</span>=<span class="summary-sig-default">None</span>,
449 <span class="summary-sig-arg">smart_strings</span>=<span class="summary-sig-default">True</span>,
450 <span class="summary-sig-arg">**_variables</span>)</span><br />
451 XPath evaluate in context of document.</td>
452 <td align="right" valign="top">
462 <td width="15%" align="right" valign="top" class="summary">
463 <span class="summary-type"> </span>
464 </td><td class="summary">
465 <table width="100%" cellpadding="0" cellspacing="0" border="0">
467 <td><span class="summary-sig"><a href="lxml.etree._ElementTree-class.html#xslt" class="summary-sig-name">xslt</a>(<span class="summary-sig-arg">self</span>,
468 <span class="summary-sig-arg">_xslt</span>,
469 <span class="summary-sig-arg">extensions</span>=<span class="summary-sig-default">None</span>,
470 <span class="summary-sig-arg">access_control</span>=<span class="summary-sig-default">None</span>,
471 <span class="summary-sig-arg">**_kw</span>)</span><br />
472 Transform this document using other document.</td>
473 <td align="right" valign="top">
483 <td colspan="2" class="summary">
484 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
485 <code>__delattr__</code>,
486 <code>__format__</code>,
487 <code>__getattribute__</code>,
488 <code>__hash__</code>,
489 <code>__init__</code>,
490 <code>__reduce__</code>,
491 <code>__reduce_ex__</code>,
492 <code>__repr__</code>,
493 <code>__setattr__</code>,
494 <code>__sizeof__</code>,
495 <code>__str__</code>,
496 <code>__subclasshook__</code>
501 <!-- ==================== PROPERTIES ==================== -->
502 <a name="section-Properties"></a>
503 <table class="summary" border="1" cellpadding="3"
504 cellspacing="0" width="100%" bgcolor="white">
505 <tr bgcolor="#70b0f0" class="table-header">
506 <td colspan="2" class="table-header">
507 <table border="0" cellpadding="0" cellspacing="0" width="100%">
509 <td align="left"><span class="table-header">Properties</span></td>
510 <td align="right" valign="top"
511 ><span class="options">[<a href="#section-Properties"
512 class="privatelink" onclick="toggle_private();"
513 >hide private</a>]</span></td>
519 <td width="15%" align="right" valign="top" class="summary">
520 <span class="summary-type"> </span>
521 </td><td class="summary">
522 <a name="docinfo"></a><span class="summary-name">docinfo</span><br />
523 Information about the document provided by parser and DTD. This
524 value is only defined for ElementTree objects based on the root node
525 of a parsed document (e.g. those returned by the parse functions),
526 not for trees that were built manually.
530 <td width="15%" align="right" valign="top" class="summary">
531 <span class="summary-type"> </span>
532 </td><td class="summary">
533 <a name="parser"></a><span class="summary-name">parser</span><br />
534 The parser that was used to parse the document in this ElementTree.
538 <td colspan="2" class="summary">
539 <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
540 <code>__class__</code>
545 <!-- ==================== METHOD DETAILS ==================== -->
546 <a name="section-MethodDetails"></a>
547 <table class="details" border="1" cellpadding="3"
548 cellspacing="0" width="100%" bgcolor="white">
549 <tr bgcolor="#70b0f0" class="table-header">
550 <td colspan="2" class="table-header">
551 <table border="0" cellpadding="0" cellspacing="0" width="100%">
553 <td align="left"><span class="table-header">Method Details</span></td>
554 <td align="right" valign="top"
555 ><span class="options">[<a href="#section-MethodDetails"
556 class="privatelink" onclick="toggle_private();"
557 >hide private</a>]</span></td>
563 <a name="__new__"></a>
565 <table class="details" border="1" cellpadding="3"
566 cellspacing="0" width="100%" bgcolor="white">
568 <table width="100%" cellpadding="0" cellspacing="0" border="0">
569 <tr valign="top"><td>
570 <h3 class="epydoc"><span class="sig"><span class="sig-name">__new__</span>(<span class="sig-arg">T</span>,
571 <span class="sig-arg">S</span>,
572 <span class="sig-arg">...</span>)</span>
574 </td><td align="right" valign="top"
581 <dt>Returns: a new object with type S, a subtype of T</dt>
590 <table class="details" border="1" cellpadding="3"
591 cellspacing="0" width="100%" bgcolor="white">
593 <table width="100%" cellpadding="0" cellspacing="0" border="0">
594 <tr valign="top"><td>
595 <h3 class="epydoc"><span class="sig"><span class="sig-name">find</span>(<span class="sig-arg">self</span>,
596 <span class="sig-arg">path</span>,
597 <span class="sig-arg">namespaces</span>=<span class="sig-default">None</span>)</span>
599 </td><td align="right" valign="top"
604 <p>Finds the first toplevel element with given tag. Same as
605 <tt class="rst-rst-docutils literal rst-docutils literal"><span class="pre">tree.getroot().find(path)</span></tt>.</p>
606 <p>The optional <tt class="rst-docutils literal">namespaces</tt> argument accepts a
607 prefix-to-namespace mapping that allows the usage of XPath
608 prefixes in the path expression.</p>
613 <a name="findall"></a>
615 <table class="details" border="1" cellpadding="3"
616 cellspacing="0" width="100%" bgcolor="white">
618 <table width="100%" cellpadding="0" cellspacing="0" border="0">
619 <tr valign="top"><td>
620 <h3 class="epydoc"><span class="sig"><span class="sig-name">findall</span>(<span class="sig-arg">self</span>,
621 <span class="sig-arg">path</span>,
622 <span class="sig-arg">namespaces</span>=<span class="sig-default">None</span>)</span>
624 </td><td align="right" valign="top"
629 <p>Finds all elements matching the ElementPath expression. Same as
630 getroot().findall(path).</p>
631 <p>The optional <tt class="rst-docutils literal">namespaces</tt> argument accepts a
632 prefix-to-namespace mapping that allows the usage of XPath
633 prefixes in the path expression.</p>
638 <a name="findtext"></a>
640 <table class="details" border="1" cellpadding="3"
641 cellspacing="0" width="100%" bgcolor="white">
643 <table width="100%" cellpadding="0" cellspacing="0" border="0">
644 <tr valign="top"><td>
645 <h3 class="epydoc"><span class="sig"><span class="sig-name">findtext</span>(<span class="sig-arg">self</span>,
646 <span class="sig-arg">path</span>,
647 <span class="sig-arg">default</span>=<span class="sig-default">None</span>,
648 <span class="sig-arg">namespaces</span>=<span class="sig-default">None</span>)</span>
650 </td><td align="right" valign="top"
655 <p>Finds the text for the first element matching the ElementPath
656 expression. Same as getroot().findtext(path)</p>
657 <p>The optional <tt class="rst-docutils literal">namespaces</tt> argument accepts a
658 prefix-to-namespace mapping that allows the usage of XPath
659 prefixes in the path expression.</p>
664 <a name="getiterator"></a>
666 <table class="details" border="1" cellpadding="3"
667 cellspacing="0" width="100%" bgcolor="white">
669 <table width="100%" cellpadding="0" cellspacing="0" border="0">
670 <tr valign="top"><td>
671 <h3 class="epydoc"><span class="sig"><span class="sig-name">getiterator</span>(<span class="sig-arg">self</span>,
672 <span class="sig-arg">tag</span>=<span class="sig-default">None</span>)</span>
674 </td><td align="right" valign="top"
679 <p>Returns a sequence or iterator of all elements in document order
680 (depth first pre-order), starting with the root element.</p>
681 <p>Can be restricted to find only elements with a specific tag
682 (pass <tt class="rst-docutils literal"><span class="pre">tag="xyz"</span></tt> or <tt class="rst-docutils literal"><span class="pre">tag="{ns}xyz"</span></tt>) or from a namespace
683 (pass <tt class="rst-docutils literal"><span class="pre">tag="{ns}*"</span></tt>).</p>
684 <p>You can also pass the Element, Comment, ProcessingInstruction and
685 Entity factory functions to look only for the specific element type.</p>
688 <div class="fields"> <p><strong>Deprecated:</strong>
689 Note that this method is deprecated as of
690 ElementTree 1.3 and lxml 2.0. It returns an iterator in
691 lxml, which diverges from the original ElementTree
692 behaviour. If you want an efficient iterator, use the
693 <tt class="rst-rst-docutils literal rst-docutils literal">tree.iter()</tt> method instead. You should only use this
694 method in new code if you require backwards compatibility
695 with older versions of lxml or ElementTree.
697 </div></td></tr></table>
699 <a name="iterfind"></a>
701 <table class="details" border="1" cellpadding="3"
702 cellspacing="0" width="100%" bgcolor="white">
704 <table width="100%" cellpadding="0" cellspacing="0" border="0">
705 <tr valign="top"><td>
706 <h3 class="epydoc"><span class="sig"><span class="sig-name">iterfind</span>(<span class="sig-arg">self</span>,
707 <span class="sig-arg">path</span>,
708 <span class="sig-arg">namespaces</span>=<span class="sig-default">None</span>)</span>
710 </td><td align="right" valign="top"
715 <p>Iterates over all elements matching the ElementPath expression.
716 Same as getroot().iterfind(path).</p>
717 <p>The optional <tt class="rst-docutils literal">namespaces</tt> argument accepts a
718 prefix-to-namespace mapping that allows the usage of XPath
719 prefixes in the path expression.</p>
724 <a name="relaxng"></a>
726 <table class="details" border="1" cellpadding="3"
727 cellspacing="0" width="100%" bgcolor="white">
729 <table width="100%" cellpadding="0" cellspacing="0" border="0">
730 <tr valign="top"><td>
731 <h3 class="epydoc"><span class="sig"><span class="sig-name">relaxng</span>(<span class="sig-arg">self</span>,
732 <span class="sig-arg">relaxng</span>)</span>
734 </td><td align="right" valign="top"
739 <p>Validate this document using other document.</p>
740 <p>The relaxng argument is a tree that should contain a Relax NG schema.</p>
741 <p>Returns True or False, depending on whether validation
743 <p>Note: if you are going to apply the same Relax NG schema against
744 multiple documents, it is more efficient to use the RelaxNG
752 <table class="details" border="1" cellpadding="3"
753 cellspacing="0" width="100%" bgcolor="white">
755 <table width="100%" cellpadding="0" cellspacing="0" border="0">
756 <tr valign="top"><td>
757 <h3 class="epydoc"><span class="sig"><span class="sig-name">write</span>(<span class="sig-arg">self</span>,
758 <span class="sig-arg">file</span>,
759 <span class="sig-arg">encoding</span>=<span class="sig-default">None</span>,
760 <span class="sig-arg">method</span>=<span class="sig-default">"xml"</span>,
761 <span class="sig-arg">pretty_print</span>=<span class="sig-default">False</span>,
762 <span class="sig-arg">xml_declaration</span>=<span class="sig-default">None</span>,
763 <span class="sig-arg">with_tail</span>=<span class="sig-default">True</span>,
764 <span class="sig-arg">standalone</span>=<span class="sig-default">None</span>,
765 <span class="sig-arg">compression</span>=<span class="sig-default">0</span>,
766 <span class="sig-arg">exclusive</span>=<span class="sig-default">False</span>,
767 <span class="sig-arg">with_comments</span>=<span class="sig-default">True</span>)</span>
769 </td><td align="right" valign="top"
774 <p>Write the tree to a filename, file or file-like object.</p>
775 <p>Defaults to ASCII encoding and writing a declaration as needed.</p>
776 <p>The keyword argument 'method' selects the output method:
777 'xml', 'html', 'text' or 'c14n'. Default is 'xml'.</p>
778 <p>The <tt class="rst-docutils literal">exclusive</tt> and <tt class="rst-docutils literal">with_comments</tt> arguments are only
779 used with C14N output, where they request exclusive and
780 uncommented C14N serialisation respectively.</p>
781 <p>Passing a boolean value to the <tt class="rst-docutils literal">standalone</tt> option will
782 output an XML declaration with the corresponding
783 <tt class="rst-docutils literal">standalone</tt> flag.</p>
784 <p>The <tt class="rst-docutils literal">compression</tt> option enables GZip compression level 1-9.</p>
789 <a name="write_c14n"></a>
791 <table class="details" border="1" cellpadding="3"
792 cellspacing="0" width="100%" bgcolor="white">
794 <table width="100%" cellpadding="0" cellspacing="0" border="0">
795 <tr valign="top"><td>
796 <h3 class="epydoc"><span class="sig"><span class="sig-name">write_c14n</span>(<span class="sig-arg">self</span>,
797 <span class="sig-arg">file</span>,
798 <span class="sig-arg">exclusive</span>=<span class="sig-default">False</span>,
799 <span class="sig-arg">with_comments</span>=<span class="sig-default">True</span>,
800 <span class="sig-arg">compression</span>=<span class="sig-default">0</span>)</span>
802 </td><td align="right" valign="top"
807 <p>C14N write of document. Always writes UTF-8.</p>
808 <p>The <tt class="rst-docutils literal">compression</tt> option enables GZip compression level 1-9.</p>
813 <a name="xinclude"></a>
815 <table class="details" border="1" cellpadding="3"
816 cellspacing="0" width="100%" bgcolor="white">
818 <table width="100%" cellpadding="0" cellspacing="0" border="0">
819 <tr valign="top"><td>
820 <h3 class="epydoc"><span class="sig"><span class="sig-name">xinclude</span>(<span class="sig-arg">self</span>)</span>
822 </td><td align="right" valign="top"
827 <p>Process the XInclude nodes in this document and include the
828 referenced XML fragments.</p>
829 <p>There is support for loading files through the file system, HTTP and
831 <p>Note that XInclude does not support custom resolvers in Python space
832 due to restrictions of libxml2 <= 2.6.29.</p>
837 <a name="xmlschema"></a>
839 <table class="details" border="1" cellpadding="3"
840 cellspacing="0" width="100%" bgcolor="white">
842 <table width="100%" cellpadding="0" cellspacing="0" border="0">
843 <tr valign="top"><td>
844 <h3 class="epydoc"><span class="sig"><span class="sig-name">xmlschema</span>(<span class="sig-arg">self</span>,
845 <span class="sig-arg">xmlschema</span>)</span>
847 </td><td align="right" valign="top"
852 <p>Validate this document using other document.</p>
853 <p>The xmlschema argument is a tree that should contain an XML Schema.</p>
854 <p>Returns True or False, depending on whether validation
856 <p>Note: If you are going to apply the same XML Schema against
857 multiple documents, it is more efficient to use the XMLSchema
865 <table class="details" border="1" cellpadding="3"
866 cellspacing="0" width="100%" bgcolor="white">
868 <table width="100%" cellpadding="0" cellspacing="0" border="0">
869 <tr valign="top"><td>
870 <h3 class="epydoc"><span class="sig"><span class="sig-name">xpath</span>(<span class="sig-arg">self</span>,
871 <span class="sig-arg">_path</span>,
872 <span class="sig-arg">namespaces</span>=<span class="sig-default">None</span>,
873 <span class="sig-arg">extensions</span>=<span class="sig-default">None</span>,
874 <span class="sig-arg">smart_strings</span>=<span class="sig-default">True</span>,
875 <span class="sig-arg">**_variables</span>)</span>
877 </td><td align="right" valign="top"
882 <p>XPath evaluate in context of document.</p>
883 <p><tt class="rst-docutils literal">namespaces</tt> is an optional dictionary with prefix to namespace URI
884 mappings, used by XPath. <tt class="rst-docutils literal">extensions</tt> defines additional extension
886 <p>Returns a list (nodeset), or bool, float or string.</p>
887 <p>In case of a list result, return Element for element nodes,
888 string for text and attribute values.</p>
889 <p>Note: if you are going to apply multiple XPath expressions
890 against the same document, it is more efficient to use
891 XPathEvaluator directly.</p>
898 <table class="details" border="1" cellpadding="3"
899 cellspacing="0" width="100%" bgcolor="white">
901 <table width="100%" cellpadding="0" cellspacing="0" border="0">
902 <tr valign="top"><td>
903 <h3 class="epydoc"><span class="sig"><span class="sig-name">xslt</span>(<span class="sig-arg">self</span>,
904 <span class="sig-arg">_xslt</span>,
905 <span class="sig-arg">extensions</span>=<span class="sig-default">None</span>,
906 <span class="sig-arg">access_control</span>=<span class="sig-default">None</span>,
907 <span class="sig-arg">**_kw</span>)</span>
909 </td><td align="right" valign="top"
914 <p>Transform this document using other document.</p>
915 <p>xslt is a tree that should be XSLT
916 keyword parameters are XSLT transformation parameters.</p>
917 <p>Returns the transformed tree.</p>
918 <p>Note: if you are going to apply the same XSLT stylesheet against
919 multiple documents, it is more efficient to use the XSLT
926 <!-- ==================== NAVIGATION BAR ==================== -->
927 <table class="navbar" border="0" width="100%" cellpadding="0"
928 bgcolor="#a0c0ff" cellspacing="0">
931 <th> <a
932 href="lxml-module.html">Home</a> </th>
935 <th> <a
936 href="module-tree.html">Trees</a> </th>
939 <th> <a
940 href="identifier-index.html">Indices</a> </th>
943 <th> <a
944 href="help.html">Help</a> </th>
946 <!-- Project homepage -->
947 <th class="navbar" align="right" width="100%">
948 <table border="0" cellpadding="0" cellspacing="0">
949 <tr><th class="navbar" align="center"
950 ><a class="navbar" target="_top" href="/">lxml API</a></th>
954 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
956 <td align="left" class="footer">
957 Generated by Epydoc 3.0.1 on Tue Jul 31 10:14:18 2012
959 <td align="right" class="footer">
960 <a target="mainFrame" href="http://epydoc.sourceforge.net"
961 >http://epydoc.sourceforge.net</a>
966 <script type="text/javascript">
968 // Private objects are initially displayed (because if
969 // javascript is turned off then we want them to be
970 // visible); but by default, we want to hide them. So hide
971 // them unless we have a cookie that says to show them.