Menu

How to use the generated python XML structure to create a XML file

2023-03-14
2023-03-17
  • Valerio Miccoli

    Valerio Miccoli - 2023-03-14

    Hi,
    first of all i want to say thanks for creating generateDS.
    I'm managing a vacation house and I need to give the city tourist office an xml report that has some information about the tourist tax payment. Those info are spread across two different management platforms, so I created some python code that takes the data I need from different reports and groups them in a Pandas DataFrame.
    Then, from an xml report example i created an XSD Schema (the attached file).

    What I thought I could do is to use generateDS to create a python model of the xml file that would allow me to create a python instance of the XML document, populate it with the data in the DataFrame, and finally write the corresponding xml file. Is that possible? the generateDS demos seem to explain how to use the generated code to validate an already existing xml file, but that's not my case: I have the data in the DataFrame and I have the python model of the xml structure (generated by generateDS), but I don't know how to fill this model with the data and I don't know how to tell the model to write the xml file.

    i would really appreciate some pieces of advice :D

    thanks again
    Vale

     
  • Laurenz Seidel

    Laurenz Seidel - 2023-03-17

    Hi there,

    Have a look at Section 6.2 of the introduction and tutorial.

    From how I understand your problem, you would need to have a look at the classes generated by generateDS and how they create instances. Then you can create those instances yourself using your DataFrames. In the tutorial, the section shows this for an example and then also exports the resulting XML.

    Hope that helps, good luck!

     

    Last edit: Laurenz Seidel 2023-03-17

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.