
March 31st, 2004, 02:35 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
adding info to xml files
###########################
import xml.dom.minidom
from xml.dom.minidom import getDOMImplementation
output = open("book1.xml", "w")
impl = getDOMImplementation()
newdoc = impl.createDocument(None, "library", None)
book = newdoc.createElement("book")
newdoc.documentElement.appendChild(book)
chapter = newdoc.createElement("chapter")
book.appendChild(chapter)
page = newdoc.createElement("page")
pageContent = newdoc.createTextNode("somerandomtext")
page.appendChild(pageContent)
chapter.appendChild(page)
output.writelines(newdoc.toprettyxml())
#########################
after i create the xml file... how can i retrieve it and add some info to it... for example how can i add another page to chapter... or another chapter to book...any help would be greatly appreciated...
|