帮忙看下html转化为xml有什么问题呢?
def flawcoverRead(self):
file = open(self.inputdir)
rst = file.read()
"""</b> (buffer) <i> --> </b> <type> (buffer) </type> <i>"""
"""</i> --> </i></li>"""
xmlstr = '<ul>' + rst.split('<ul>')[1].split('</ul>')[0] + '</ul>'
xmlstr = xmlstr.replace("</b>", "</b><type>").replace("<i>", "</type><i>").replac("</i>", "</i></li>")
root = etree.fromstring(xmlstr)
xmlrst = []
for c in root:
els = []
file, line = c.text.split(':')[:-1]
els.append(file)
els.append(line)
level, ty, msg = [i.text.strip() for i in c]
level = level[1]
ty = ty[1:-1]
temp = msg.split(":")
func = temp[0]
msg = ''.join(temp[1:]).strip().replace("\n", '')
els.append(level)
els.append(ty)
els.append(func)
els.append(msg)
xmlrst.append(els)
return xmlrst