[Tutor] How to store output of Python program in XML

Alan Gauld alan.gauld at yahoo.co.uk
Sat Jul 13 05:31:42 EDT 2019


On 13/07/2019 07:40, Asad wrote:

> want to print the output of the script in a xml file so that I can add some
> tags . How can it be done ?

XML is just text dso you can just use the normal Python string
operations to format an XML string with your data.

However there are XML libraries aplenty that can aid you in
constructing a valid XML tree structure. The standard library
contains an xml package which includes the dom module
which might be a good starting place if you want to
understand the concepts.

The etree module is probably easier to use in the long
term though. Look at the "Building XML documents" section
in the etree documentation.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list