Answer the question
In order to leave comments, you need to log in
How to make xml with xsd and fill it with data?
I have xsd and I need xml with the data that I want to fill in, tell me how to do it . But I consider different libraries, the easier it solves the problem, the better.
Answer the question
In order to leave comments, you need to log in
Forgive me for the answer from SO ( link ), but someone will obviously need these here.
import xmlschema
import json
from xml.etree.ElementTree import ElementTree
my_xsd = '<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="note" type="xs:string"/> </xs:schema>'
schema = xmlschema.XMLSchema(my_xsd)
data = json.dumps({'note': 'this is a Note text'})
xml = xmlschema.from_json(data, schema=schema, preserve_root=True)
ElementTree(xml).write('my_xml.xml')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question