diff emeraldtree/ElementTree.py @ 37:4bb8fc436265

ElementTree - Add real iterator to Element
author Bastian Blank <bblank@thinkmo.de>
date Mon, 14 Jul 2008 15:03:10 +0200
parents 29ab13148a54
children 6e38bcef6030
line wrap: on
line diff
--- a/emeraldtree/ElementTree.py	Mon Jul 14 14:40:22 2008 +0200
+++ b/emeraldtree/ElementTree.py	Mon Jul 14 15:03:10 2008 +0200
@@ -372,6 +372,15 @@
     def items(self):
         return self.attrib.items()
 
+    def __iter__(self):
+        """
+        Creates a element iterator.  The iterator loops over all (non text)
+        children.
+        """
+        for e in self._children:
+            if isinstance(e, Node):
+                yield e
+
     ##
     # Creates a tree iterator.  The iterator loops over this element
     # and all subelements, in document order, and returns all elements