[Solved] parsing outbound message in python

sujit tiwari Asks: parsing outbound message in python
I am capturing outbound message from salesforce as a POST

Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
    <OrganizationId>00D280000011nfmEAA</OrganizationId>
    <ActionId>04k280000008RaNAAU</ActionId>
    <SessionId>00D280000011nfm!AQkAQP0UUCMjx45Y8JUjboFldPYjgUE_GsERgn6zkrhzIqiq4bnabtPWRo..eOE7q_pVQREdkKMi3cHtem5OoW4swVbYX1c1</SessionId>
    <EnterpriseUrl>https://ap2.salesforce.com/services/Soap/c/34.0/00D280000011nfm</EnterpriseUrl>
    <PartnerUrl>https://ap2.salesforce.com/services/Soap/u/34.0/00D280000011nfm</PartnerUrl>
    <Notification>
      <Id>04l28000000HkGRAA0</Id>
      <sObject xsi:type="sf:Account" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
        <sf:Id>001280000077HXLAA2</sf:Id>
        <sf:Name>University Of Hyderabad</sf:Name>
        <sf:Phone>(898) 549-5538</sf:Phone>
      </sObject>
    </Notification>
   </notifications>
 </soapenv:Body>
</soapenv:Envelope>

and want to parse it using python, but getting an error

Code:
XML or text declaration not at start of entity: line 2, column 0

My code sample is

Code:
from twisted.web import server, resource
from twisted.internet import reactor
import os
import json
import xml.etree.ElementTree as ET

class Simple(resource.Resource):
    isLeaf = True

    def render_GET(self, request):
        return "{0}".format(request.args.keys())

    def render_POST(self, request):
        #print request.getHeader('User-Agent')
        msg = request.content.read()
        #print msg
        root = ET.fromstring(msg)
        print root.tag
        for child in root:
            print(child.tag, child.attrib)
        return xmlRes

site = server.Site(Simple())
reactor.listenTCP(7080, site)
reactor.run()

Any help will be appreciable.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.