3

I was trying to export all themes and its corresponding layers information through PyQGIS so that xml can be read later .There is method in Class: QgsMapThemeCollection, writeXml(self, doc: QDomDocument) but cannot able to write into xml file.

Below code has been tried but cannot able to write.

doc = QDomDocument()
qgsl = QgsProject.instance()
mTC = qgsl.mapThemesCollection()
mTs = mTC.mapThemes()
mTc.writeXml(doc)
3

This works for me:

doc = QDomDocument()
qgsl = QgsProject.instance()
mTC = qgsl.mapThemeCollection() # and *not* mapThemesCollection()
mTs = mTC.mapThemes()
mTC.writeXml(doc) # note the variable name change
1
  • thanks for reply.Can you please share the way to import generated xml file and location of stored xml file.
    – Devenepali
    Apr 9 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.