[Lxml-checkins] r50995 - in lxml/trunk: . doc
scoder at codespeak.net
scoder at codespeak.net
Thu Jan 24 21:56:58 CET 2008
Author: scoder
Date: Thu Jan 24 21:56:56 2008
New Revision: 50995
Modified:
lxml/trunk/ (props changed)
lxml/trunk/doc/FAQ.txt
Log:
r3306 at delle: sbehnel | 2008-01-24 21:56:35 +0100
FAQ update
Modified: lxml/trunk/doc/FAQ.txt
==============================================================================
--- lxml/trunk/doc/FAQ.txt (original)
+++ lxml/trunk/doc/FAQ.txt Thu Jan 24 21:56:56 2008
@@ -157,10 +157,30 @@
>>> print etree.tostring(root[0])
<tag>text<child/></tag>tail
-This is a huge simplification for the tree model as it avoids text nodes to
-appear in the list of children and makes access to them quick and simple. So
-this is a benefit in most applications and simplifies many, many XML tree
-algorithms.
+Here is an example that shows why the opposite behaviour would be even
+more unexpected::
+
+ >>> root = et.Element("test")
+
+ >>> root.text = "TEXT"
+ >>> et.tostring(root)
+ <test>TEXT</test>
+
+ >>> et.tail = "TAIL"
+ >>> et.tostring(root)
+ <test>TEXT</test>TAIL
+
+ >>> et.tail = None
+ >>> et.tostring(root)
+ <test>TEXT</test>
+
+Just imagine a Python list where you append an item and it doesn't
+show up when you look at the list.
+
+The ``.tail`` property is a huge simplification for the tree model as
+it avoids text nodes to appear in the list of children and makes
+access to them quick and simple. So this is a benefit in most
+applications and simplifies many, many XML tree algorithms.
However, in document-like XML (and especially HTML), the above result can be
unexpected to new users and can sometimes require a bit more overhead. A good
More information about the lxml-checkins
mailing list