Create XML from Python dict and export to PDF and XLS

589 views Asked by At

Good afternoon.

My question is on general workflow/procedure on how to create a basic XML document from Python dictionary so that it can be converted both to PDF and XLS? It's going to contain tables, graphs (as images) and some text.

I've been researching on the object for while, but the amount of information on topic makes me feel somewhat lost. For now I've managed to convert my dictionary to XML document using "xml" Python package (it was kind of hardcoding - I wrote few functions to have work done, guess there must be some automated tools for that).

What is the next step? From Wikipedia and some other sources I guess I should create XSL styles document so that my custom XML could be processed to "general-view" XML document that is exportable to XLS/PDF? Am I right and what are the best tools/packages for that?

1

There are 1 answers

0
Surya Teja On

Try the following code to convert a dictionary to xml file

import dicttoxml
s = { 'name': 'surya', 'shares': 100, 'price': 500 }
f=open("a.xml","w")
xml = dicttoxml.dicttoxml(s)
f.write(xml)

Its upto xml file creation but how to convert pdf is upto you.

If any solution is found ... plz do post here :)