The structure of the XML is as following:
<jobs>
<job>
...
</job>
</jobs>
If there is more than one job
element within jobs
, the library xmltodict generates an additional list. around all jobs.
In case of multiple jobs:
{'jobs': {'job': [{ job1 }, { job2 }]}}
In case of one job:
{'jobs': {'job': { job1 }}}
How do I prevent this from happening because it messes up my code in displaying the job(s) on a website?
I already tried to convert the dictionary to a string and removing the []. But there has to be a more elegant solution.