Good Afternoon All.
I will preface this question by saying that this is my first foray into Python. I am using an API to return the following XML sample:
<Times>
<Time>
<ID> 120877787 </ID>
<Job>
<ID> J000050 </ID>
<Name> My Job </Name>
</Job>
<Task>
<ID> 59469972 </ID>
<Name> My Task </Name>
</Task>
<Staff>
<ID> 74268 </ID>
<Name> My Name </Name>
</Staff>
<Date> 2017-05-19T00:00:00 </Date>
<Minutes> 480 </Minutes>
<Note/>
<Billable> true </Billable>
</Time>
</Times>
I am presently in the process of converting the XML to CSV using Python 3.4.
I have done a fair bit of research (http://blog.appliedinformaticsinc.com/how-to-parse-and-convert-xml-to-csv-using-python/ for example) into resolving the issue, but I can't come up with a suitable result, primarily because I don't understand the syntax well enough to adapt it to my exact circumstance.
Basically I am looking for the following output.
Job Name Task Name Staff Name Date Minutes Billable
My Job My Task My Name 2017-05-19T00:00:00 480 true
As requested this is how the XML is returned from the API (as a string and viewed by print(ts.content)), which may be where I am going wrong.
<Times><Time><ID> 120877787 </ID><Job><ID> J000050 </ID><Name> My Job </Name></Job><Task><ID> 59469972 </ID><Name> My Task </Name></Task><Staff><ID>74268</ID><Name> My Name </Name></Staff><Date> 2017-05-19T00:00:00 </Date><Minutes> 480 </Minutes><Note/><Billable> true </Billable></Time></Times>
Could someone please offer some insight into the best way to approach this task?
Thank you for your help.
Scott