How can I change a Python object into XML?

前端 未结 2 1134
梦如初夏
梦如初夏 2020-12-18 10:43

I am looking to convert a Python object into XML data. I\'ve tried lxml, but eventually had to write custom code for saving my object as xml which isn\'t perfect.

I\

2条回答
  •  庸人自扰
    2020-12-18 11:13

    Mike,

    you can either implement object rendering into XML :

    class Person:
      ...
      def toXml( self):
        print ''
        print '\t...
        ...
        print ''
    

    or you can transform Gnosis or pyxser output using XSLT.

提交回复
热议问题