您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Python创建xml的方法

2024/4/15 6:45:25发布20次查看
本文实例讲述了python创建xml的方法。分享给大家供大家参考。具体实现方法如下:
from xml.dom.minidom import documentclass write_xml(document): def __init__(self): document.__init__(self) def set_tag(self,tag): self.tag = tag self.tag1 = self.createelement(self.tag) self.appendchild(self.tag1) self.maincard = self.createelement(card) self.maincard.setattribute(id, main) self.maincard.setattribute(id2,main2) self.tag1.appendchild(self.maincard) self.paragraph1 = self.createelement(p) self.maincard.appendchild(self.paragraph1) self.ptext = self.createtextnode(this is a test!) self.paragraph1.appendchild(self.ptext) def display(self): print self.toprettyxml(indent= )wx = write_xml()wx.set_tag('test')wx.display()
希望本文所述对大家的python程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product