Generating xml in python and lxml

前端 未结 4 980
逝去的感伤
逝去的感伤 2020-12-25 08:21

I have this xml from sql, and I want to do the same by python 2.7 and lxml



  

        
4条回答
  •  梦毁少年i
    2020-12-25 08:54

    Save to XML file

    doc.write('output.xml', xml_declaration=True, encoding='utf-16') 
    

    instead of:

    outFile = open('output.xml', 'w')
    
    doc.write(outFile, xml_declaration=True, encoding='utf-16') 
    

提交回复
热议问题