'This method will discard the output the shell sends, it will read it from
the xml where it expects it to be present.
NOTE: if \'debug\' is true then it is being run from a test case and the
output being sent is valid.'

def parseOutputString(self, output, debug=False):

    parser = OpenvasXmlParser(output)
    web = False
    ids = {}
    for item in parser.items:
        if (item.name is not None):
            ref = []
            if item.cve:
                ref.append(item.cve.encode('utf-8'))
            if item.bid:
                ref.append(item.bid.encode('utf-8'))
            if item.xref:
                ref.append(item.xref.encode('utf-8'))
            if ids.has_key(item.subnet):
                h_id = ids[item.host]
            else:
                h_id = self.createAndAddHost(item.subnet)
                ids[item.subnet] = h_id
            if (item.port == 'None'):
                v_id = self.createAndAddVulnToHost(h_id, item.name.encode('utf-8'), desc=item.description.encode('utf-8'), severity=item.severity.encode('utf-8'), ref=ref)
            else:
                if item.service:
                    web = (True if re.search('^(www|http)', item.service) else False)
                else:
                    web = (True if (item.port in ('80', '443', '8080')) else False)
                if ids.has_key(((item.subnet + '_') + item.subnet)):
                    i_id = ids[((item.subnet + '_') + item.subnet)]
                else:
                    if self._isIPV4(item.subnet):
                        i_id = self.createAndAddInterface(h_id, item.subnet, ipv4_address=item.subnet, hostname_resolution=item.host)
                    else:
                        i_id = self.createAndAddInterface(h_id, item.subnet, ipv6_address=item.subnet, hostname_resolution=item.host)
                    ids[((item.subnet + '_') + item.subnet)] = i_id
                if ids.has_key(((item.subnet + '_') + item.port)):
                    s_id = ids[((item.subnet + '_') + item.port)]
                else:
                    s_id = self.createAndAddServiceToInterface(h_id, i_id, item.service, item.protocol, ports=[str(item.port)], status='open')
                    ids[((item.subnet + '_') + item.port)] = s_id
                    if web:
                        n_id = self.createAndAddNoteToService(h_id, s_id, 'website', '')
                        self.createAndAddNoteToNote(h_id, s_id, n_id, item.host, '')
                if item.name:
                    if web:
                        v_id = self.createAndAddVulnWebToService(h_id, s_id, item.name.encode('utf-8'), desc=item.description.encode('utf-8'), website=item.host, severity=item.severity.encode('utf-8'), ref=ref)
                    else:
                        self.createAndAddVulnToService(h_id, s_id, item.name.encode('utf-8'), desc=item.description.encode('utf-8'), severity=item.severity.encode('utf-8'), ref=ref)
    del parser
