summaryrefslogtreecommitdiff
path: root/suds/sax/element.py
diff options
context:
space:
mode:
Diffstat (limited to 'suds/sax/element.py')
-rw-r--r--suds/sax/element.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/suds/sax/element.py b/suds/sax/element.py
index ca44801..0a015f1 100644
--- a/suds/sax/element.py
+++ b/suds/sax/element.py
@@ -923,6 +923,41 @@ class Element:
def __unicode__(self):
return self.str()
+
+ def __iter__(self):
+ return NodeIterator(self)
+
+
+class NodeIterator:
+ """
+ The L{Element} child node iterator.
+ @ivar pos: The current position
+ @type pos: int
+ @ivar children: A list of a child nodes.
+ @type children: [L{Element},..]
+ """
+
+ def __init__(self, parent):
+ """
+ @param parent: An element to iterate.
+ @type parent: L{Element}
+ """
+ self.pos = 0
+ self.children = parent.children
+
+ def next(self):
+ """
+ Get the next child.
+ @return: The next child.
+ @rtype: L{Element}
+ @raise StopIterator: At the end.
+ """
+ try:
+ child = self.children[self.pos]
+ self.pos += 1
+ return child
+ except:
+ raise StopIteration()
class PrefixNormalizer: