def GetAttributeValue(attr, extract=True):
"""
Function that extracts data from a tree node
@param attr: tree node containing data to extract
@param extract: attr is a tree node or not
@return: data extracted as string
"""
if not extract:
return attr
if len(attr.childNodes) == 1:
return unicode(unescape(attr.childNodes[0].data))
else:
# content is a CDATA
text = u''
for node in attr.childNodes:
if not (node.nodeName == "#text" and node.data.strip() == u''):
text += unicode(unescape(node.data))
return text
评论列表
文章目录