Python Suds raw XML vs parsed value differnce

693 Views Asked by At

In Suds, I use something like

client = suds.client.Client(url)

date_val = client.service.getDate()

and date_val is printed as

2013-11-16

If I use client.last_received(), the raw xml gets printed as

2013-12-11-05:00

How do I get the date returned to date_val to be returned as 2013-11-16-05:00 ?

1

There are 1 best solutions below

0
On

Apparently this is a known issue with suds. It finds the datetime and returns datetime.date. I couldn't figure out how to change this so I used something like the following:

def getElementFromRawXML(raw_xml,element):
    string_xml = raw_xml.plain()
    begin = string_xml.find("<"+element+">")
    end = string_xml.find("</"+element+">")
    if begin == -1 or end == -1:
        return None
    else:
        return string_xml[(begin+len(element)+2):end]

raw_xml = client.last_received() 
print getELementFromRawXML(raw_xml,'date')