# Slixmpp: The Slick XMPP Library# Copyright (C) 2012 Nathanael C. Fritz# This file is part of Slixmpp.# See the file LICENSE for copying permission.fromslixmpp.stanzaimportMessagefromslixmpp.utilimportunicodefromslixmpp.xmlstreamimportElementBase,ET,register_stanza_plugin,tostringXHTML_NS='http://www.w3.org/1999/xhtml'
[docs]defget_body(self,lang=None):"""Return the contents of the HTML body."""iflangisNone:lang=self.get_lang()bodies=self.xml.findall('{%s}body'%XHTML_NS)iflang=='*':result={}forbodyinbodies:body_lang=body.attrib.get('{%s}lang'%self.xml_ns,'')body_result=[]body_result.append(body.textifbody.textelse'')forchildinbody:body_result.append(tostring(child,xmlns=XHTML_NS))body_result.append(body.tailifbody.tailelse'')result[body_lang]=''.join(body_result)returnresultelse:forbodyinbodies:ifbody.attrib.get('{%s}lang'%self.xml_ns,self.get_lang())==lang:result=[]result.append(body.textifbody.textelse'')forchildinbody:result.append(tostring(child,xmlns=XHTML_NS))result.append(body.tailifbody.tailelse'')return''.join(result)return''