2

can I build an XML file from XSD using Python?
I found that xmlschema package expected to do this but failed to found a simple working example...

For example, using the code below its not working for me:

xs = xmlschema.XMLSchema('tests/test_cases/examples/collection/collection.xsd')
pprint(xs.to_dict('tests/test_cases/examples/collection/collection.xml'))

another option is using the generateDS package.

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
Adi Ep
  • 509
  • 1
  • 5
  • 22
  • Seems unlikely in the general case - it's a bit like saying "could you draw me a map of roads and rivers (the XML file) if all roads are coloured red and rivers blue (the schema)?" – DisappointedByUnaccountableMod Feb 12 '20 at 16:21
  • Don't tell us that something doesn't work, tell us how it fails. We can't diagnose a problem without knowing the symptoms. – Michael Kay Feb 12 '20 at 18:37
  • It would also be useful to know _why_ you want to do this. – kimbert Feb 13 '20 at 09:46
  • I get an error: failed with: xml pycharm: xsd-> xml but I need the code for doing this... Pycahrm--> Tools | XML Actions | Generate XML Document from XSD Schema – Adi Ep Feb 13 '20 at 11:20
  • There is also online link for this: http://xsd2xml.com/ (its get some example xml can created from this xsd....) – Adi Ep Feb 13 '20 at 11:34

0 Answers0