python use dom to write xml file
2013-07-11 10:59
573 查看
#encoding:utf-8 ''' write xml in dom style ''' from xml.dom.minidom import Document doc = Document() # new a DOM object words = doc.createElement('words') # new a root element words.setAttribute('xmlns:xsi',"http://www.w3.org/2001/XMLSchema-instance")#设置命名空间 doc.appendChild(words) elem = doc.createElement('word') elem.setAttribute('name','english') words.appendChild(elem) # or you could do like the following: #elem = doc.createElement('word') #words.appendChild(elem) #text = doc.createElement('name') #text_node = doc.createTextNode('english') #text.appendChild(text_node) #elem.appendChild(text) print doc.toxml()
相关文章推荐
- Use Dom4J to Write XML file
- Use Jdom to Write XML file
- How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
- How To Read XML File In Java – (DOM Parser)
- use python to get file list
- Use Haskell ByteString to Read/Write File
- Use jQuery To Retrieve Data From An XML File
- How to: Write Object Data to an XML File
- use python to delete visual studio temp file
- How To Create XML File In Java – (DOM Parser)
- python how to write unicode to a txt file
- Python: Write UTF-8 characters to csv file
- android发布maven报错:Could not write to file '*****/build/poms/pom-default.xml'
- utf 8 - Write to utf-8 file in python - Stack Overflow
- Load Information from XML File Contiain Namespce Use ElementTree[Python]
- The Classical Example using DOM to operate a XML File
- utf 8 - Write to utf-8 file in python - Stack Overflow
- Use Jdom to Read XML file
- writeToFile 失败
- How to Use File Choosers