class PseudoStream(object):

    def read_iterator(self):
        yield '<foo>'
yield '<bar>'
for line in open('test.xml'):
    yield line
yield '</bar>'
yield '</foo>'

def __init__(self):
    self.ri = self.read_iterator()

def read(self, *foo):
    pass
Parsing large pseudo-xml files in python