parser parse('mybooks xml'finallythe elementtree system available in the etree package of the standard library can often achieve the same effects as xml dom parsersbut with remarkably less code it' python-specific way to both parse and generate xml textafter parseits api gives access to components of the documentfile etreeparse py from xml etree elementtree import parse tree parse('mybooks xml'for in tree findall('title')print( textwhen run in either or xall four of these scripts display the same printed resultc:\codec:\python \python domparse py learning python programming python python pocket reference :\codec:\python \python domparse py learning python programming python python pocket reference technicallythoughin some of these scripts produce unicode string objectswhile in all produce str stringssince that type includes unicode text (whether ascii or other) :\codec:\python \python from xml dom minidom import parsenode xmltree parse('mybooks xml'for node in xmltree getelementsbytagname('title')for node in node childnodesif node nodetype =node text_nodenode data 'learning python'programming python'python pocket referencec:\codec:\python \python same code 'learning pythonu'programming pythonu'python pocket referenceprograms that must deal with xml parsing results in nontrivial ways will need to account for the different object type in againthoughbecause all strings have nearly identical interfaces in both and xmost scripts won' be affected by the changetools available on unicode in are generally available on str in the major featother string tool changes in