comparison emeraldtree/ElementTree.py @ 9:e0965f86912a

Fix text iterator. emeraldtree/ElementTree.py: Fix Element.textiter.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 16:19:33 +0200
parents a30d65781076
children ec93cdb38b9e
comparison
equal deleted inserted replaced
8:e1d0cd336bf3 9:e0965f86912a
507 # 507 #
508 # @return An iterator containing all inner text. 508 # @return An iterator containing all inner text.
509 # @defreturn iterator 509 # @defreturn iterator
510 510
511 def itertext(self): 511 def itertext(self):
512 if self.text:
513 yield self.text
514 for e in self: 512 for e in self:
515 for s in e.itertext(): 513 if isinstance(e, Element):
516 yield s 514 for s in e.itertext():
517 if e.tail: 515 yield s
518 yield e.tail 516 elif isinstance(e, basestring):
517 yield e
519 518
520 # compatibility 519 # compatibility
521 _Element = _ElementInterface = Element 520 _Element = _ElementInterface = Element
522 521
523 ## 522 ##