this may be a truly stupid question but I haven't readily found the answer. once i modify the xml tree as necessary, how do I write it back out to file?
code:
workbook = open("C:\\Users\\rabdel.WINCMPT\\Documents\\Retail Footwear.twb")
soup = BeautifulSoup(workbook)
for dashboard in soup.findAll("dashboard"):
print dashboard["name"]
if dashboard["name"] == "S1":
dashboard.extract()
for window in soup.findAll("window"):
print "class:",window["class"]
if "name" in [x[0] for x in window.attrs]:
print "name:",window["name"]
if window["name"] == "S1":
window.extract()
Simplest way, get the output as a string and write to file:
f = open(workbook.name, "w")
f.write(soup.prettify())
f.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With