[Tutor] Generating XML using Python

Peter Otten __peter__ at web.de
Mon Apr 11 10:39:48 CEST 2011


tee chwee liong wrote:

> thanks for your reply. seems that xml doesnt accept a space in between.
> anyway, the output generated is:
> 
> - <Test>
> 
> 
> - <Default_Config Port="8">
> 
> 
>   <LINK>2</LINK>
> 
>   <Target_Speed>3</Target_Speed>
>   </Default_Config>
>   </Test>
>  
> it overwrites every time the port number is incremented and only capture
> the last iteration number. how can i modify it to capture all the
> iteration? 

Do you want them all in one file? Move the code to create the root element 
and the code to write the file out of the loop.

Do you want to write multiple files? Use a different name from every file.



More information about the Tutor mailing list