I want to convert xml (qml) file to dictionary, then convert this dictionary to new xml. (Also want to edit something, but first lets just convert it in both way without it.)
I'm using xmltodict module to xml->dict and then dicttoxml module,dom parse to string and file.write() to dict->xml.
xml = open("path", "r") org_xml = xml.read() dict_xml = xmltodict.parse(org_xml) new_xml = dicttoxml.dicttoxml(dict_xml, custom_root = 'qgis') dom = (parseString(new_xml)).toprettyxml() with open("path/new.qml", 'a') as file: file.write(dom.encode("utf-8"))
The problem is, that while converting I 'loose' something. First file is a categorized symbol style tempale and the second is single symbol.
Anyone tried conversion like this and can help?