How can I get the text between tags using python SAX parser?

萝らか妹 提交于 2019-12-01 16:47:34

The text in the tag is chunked by the SAX processor. characters might be called multiple times.

You need to do something like:

def startElement(self, name, attrs):
    self.map[name] = ''
    self.tag = name

def characters(self, content):
    self.map[self.tag] += content

def endElement(self, name):
    print self.map[name]
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!