wolfek
wolfek

Reputation: 3

How to parse xsd and create XML's from it with python?

I'm very begginer with python and I have task to parse xsd schema to python code, fill nodes with values and create final XML file from it. Is it possible with generateDS tool? I can't find clear anwser in documentation. Maybe theres another way to do it? Thanks for anwsers

Upvotes: 0

Views: 1411

Answers (2)

wolfek
wolfek

Reputation: 3

Maybe someone in future will have same problem as I had, so there's a tip: to create objects from Schema use generateDStool, it's a way easier to use rather than pyxb

Upvotes: 0

AzyCrw4282
AzyCrw4282

Reputation: 7744

This question is rather broad to answer in a single post. So I will give the correct method that you would need to follow to solve the problem.

Firstly, XSD is the schema definition of an XML instance, essentially the rules of the XML file. Parsing is not the right word to use here, instead creating an XML instance from a XSD would be a better sound.

You would need to use pyxb to process your xml schema definitions. See this, its a good walkthrough. You can also use this library to do the same job.

Now that your definitions are processed you can then insert/delete values from your XML instance. See this for an example.

Upvotes: 0

Related Questions