def __str__(self): envelope = ElementTree.Element(_SOAPSection.ENVELOPE) if len(self.header) > 0: envelope.append(self.header) body = ElementTree.SubElement(envelope, _SOAPSection.BODY) body.append(self.method) return "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +\ ElementTree.tostring(envelope, "utf-8")
def _parse(self, data): events = ("start", "end", "start-ns", "end-ns") ns = [] data = StringIO.StringIO(data) context = ElementTree.iterparse(data, events=events) for event, elem in context: if event == "start-ns": ns.append(elem) elif event == "end-ns": ns.pop() elif event == "start": elem.set("(xmlns)", tuple(ns)) data.close() return context.root
def __str__(self): return ElementTree.tostring(self.element, "utf-8")
def _handle_UBX(self,command): # contact infos contacts = self._address_book.contacts.search_by_account(command.arguments[0]) if command.payload: for contact in contacts: data = et.fromstring(command.payload) contact._server_property_changed("personal-message", data.find("./PSM").text)