toxml([encoding]creates string containing the xml represented by node and its children encoding specifies the encoding (for example'utf- 'if no encoding is givennone is specified in the output text writexml(writer [indent [addindent [newl]]]writes xml to writer writer can be any object that provides write(method that is compatible with the file interface indent specifies the indentation of it is string that is prepended to the start of node in the output addindent is string that specifies the incremental indentation to apply to child nodes of newl specifies the newline character dom example the following example shows how to use the xml dom minidom module to parse and extract information from an xml filefrom xml dom import minidom doc minidom parse("recipe xml"ingredients items doc getelementsbytagname("ingredients")[ ingredients getelementsbytagname("item"for item in itemsnum item getattribute("num"units item getattribute("units"text item firstchild data strip(quantity "% % (num,unitsprint("%- % (quantity,text)note the xml dom minidom module has many more features for changing the parse tree and working with different kinds of xml node types more information can be found in the online documentation xml etree elementtree the xml etree elementtree module defines flexible container object elementtree for storing and manipulating hierarchical data although this object is commonly used in conjunction with xml processingit is actually quite general-purpose--serving role that' cross between list and dictionary elementtree objects the following class is used to define new elementtree object and represents the top level of hierarchy elementtree([element [file]]creates new elementtree object element is an instance representing the root node of the tree this instance supports the element interface described next file is either filename or file-like object from which xml data will be read to populate the tree lib fl ff