'Parse the incoming XML stream
Stream events are raised for each received stanza.'

def __read_xml(self):

    depth = 0
    root = None
    for (event, xml) in ET.iterparse(self.filesocket, ('end', 'start')):
        if (event == 'start'):
            if (depth == 0):
                root = xml
                log.debug(u'RECV:    %s', tostring(root, xmlns=self.default_ns, stream=self, top_level=True, open_only=True))
                self.stream_end_event.clear()
                self.start_stream_handler(root)
                self.reconnect_delay = 1.0
            depth += 1
        if (event == 'end'):
            depth -= 1
            if (depth == 0):
                log.debug(u'End    of    stream    recieved')
                self.stream_end_event.set()
                return False
            elif (depth == 1):
                try:
                    self.__spawn_event(xml)
                except RestartStream:
                    return True
                if (root is not None):
                    root.clear()
    log.debug(u'Ending    read    XML    loop')
