[Solved] parsing outbound message in python

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

<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">
  <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
      <sObject xsi:type="sf:Account" xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
        <sf:Name>University Of Hyderabad</sf:Name>
        <sf:Phone>(898) 549-5538</sf:Phone>

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

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

My code sample is

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)

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.