I did something similar to this, but couldn’t find a way to write the result to an xml file.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code on the web page you linked to uses
doc.toprettyxmlto create a string from the XML DOM, so you can just write that string to a file:In Python 2.6 (or 2.7 I suppose, whenever it comes out), you can use the ‘
with‘ statement:This also works in Python 2.5 if you put
at the beginning of the file.