要生成的xml文件格式如下:
[python]
sample xml thing
ma
xiaoju
Springs Widgets, Inc.
First
I think widgets are greate.You should buy lots of them forom
Spirngy Widgts, Inc
代码:
[python]
from xml.dom import minidom, Node
doc = minidom.Document()
doc.appendChild(doc.createComment("Simple xml document__chapter 8"))
#generate the book
book = doc.createElement('book')
doc.appendChild(book)
#the title
title = doc.createElement('title')
title.appendChild(doc.createTextNode("sample xml thing"))
book.appendChild(title)
#the author section
author = doc.createElement("author")
book.appendChild(author)
name = doc.createElement('name')
author.appendChild(name)
firstn