'NoneType' object has no attribute 'data'

Posted by Bill Jordan on Stack Overflow See other posts from Stack Overflow or by Bill Jordan
Published on 2010-06-04T18:41:44Z Indexed on 2010/06/05 22:52 UTC
Read the original article Hit count: 277

Filed under:

Hello guys,

I am sending a SOAP request to my server and getting the response back. sample of the response string is shown below:

<?xml version = '1.0' ?>
<env:Envelope xmlns:env=http:////www.w3.org/2003/05/soap-envelop
.
..
..
<env:Body>
    <epas:get-all-config-resp xmlns:epas="urn:organization:epas:soap"> ^M
...
...
<epas:property name="Tom">12</epas:property>
> 
> <epas:property name="Alice">34</epas:property>
> 
> <epas:property name="John">56</epas:property>
> 
> <epas:property name="Danial">78</epas:property>
> 
> <epas:property name="George">90</epas:property>
> 
> <epas:property name="Luise">11</epas:property>

...
^M
</env:Body?
</env:Envelop>

What I noticed in the response is that there is an extra character shown in the body which is "^M". Not sure if this could be the issue. Note the ^M shown! when I tried parsing the string returned from the server to get the names and values using the code sample:

elements = minidom.parseString(xmldoc).getElementsByTagName("property")      
myDict = {}
for element in elements:
  myDict[element.getAttribute('name')] = element.firstChild.data

But, I am getting this error: 'NoneType' object has no attribute 'data'. May be its something to do with the "^M" shown on the xml response back!

Any ideas/comments would be appreciated,

Cheers

© Stack Overflow or respective owner

Related posts about python