function tostring() to get HTML string from element
This commit is contained in:
parent
82e9108aa8
commit
612fcd1cf5
1 changed files with 9 additions and 0 deletions
|
|
@ -69,3 +69,12 @@ class StandardParser(object):
|
|||
if elem.tag.startswith('{'):
|
||||
elem.tag = elem.tag[elem.tag.find('}')+1:]
|
||||
return tree
|
||||
|
||||
def tostring(element):
|
||||
e = ElementTree.Element('body')
|
||||
e.text = element.text
|
||||
e.tail = element.tail
|
||||
for sub in element.getchildren():
|
||||
e.append(sub)
|
||||
s = ElementTree.tostring(e, 'utf-8')
|
||||
return unicode(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue