Tuesday, 8 July 2014

Is it possible to parse SOAP like xml in python?



I have custom SOAP string which i trying to parse, but cant figure out how to get elements after parse.



>>> from xml.dom.minidom import parseString
>>> print r.text
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/18hkEkn" xmlns:SOAP-ENC="http://ift.tt/1cvL1jU" xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY" xmlns:wsa5="http://ift.tt/HKXHai" xmlns:Device="http://ift.tt/1leiEPp" xmlns:tt="http://ift.tt/1cvL1Ag" xmlns:ter="http://ift.tt/1leiEyG"><SOAP-ENV:Body><Device:GetSystemDateAndTimeResponse><Device:SystemDateAndTime><tt:DateTimeType>NTP</tt:DateTimeType><tt:DaylightSavings>true</tt:DaylightSavings><tt:TimeZone><tt:TZ>GMT0BST,M3.5.0/1,M10.5.0</tt:TZ></tt:TimeZone><tt:UTCDateTime><tt:Time><tt:Hour>10</tt:Hour><tt:Minute>34</tt:Minute><tt:Second>16</tt:Second></tt:Time><tt:Date><tt:Year>2014</tt:Year><tt:Month>7</tt:Month><tt:Day>8</tt:Day></tt:Date></tt:UTCDateTime><tt:Extension><tt:Region>:Europe/London</tt:Region></tt:Extension></Device:SystemDateAndTime></Device:GetSystemDateAndTimeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
>>> response = parseString(r.text)
>>> response.getElementsByTagNameNS('*', 'body')
[]

No comments:

Post a Comment