python programming the xml document contains the graphicscommands element calling getelementsbytagname on graphicscommands returns list of all elements that match this tag name since we know there is only one of these tags in the filewe can write [ to get the first element from the list thenthe graphicscommands element contains just the one element from the file and all the command elements of the file are located within it if we want to go through all these elements we can use for loop as in the code in sect using an xml parser for commandelement in graphicscommandsprint(type(commandelement)command commandelement firstchild data strip(attr commandelement attributes if command ="goto" float(attr[" "valuey float(attr[" "valuewidth float(attr["width"valuecolor attr["color"value strip(cmd gotocommand( , ,width,color elif command ="circle"radius float(attr["radius"valuewidth float(attr["width"valuecolor attr["color"value strip(cmd circlecommand(radius,width,color elif command ="beginfill"color attr["color"value strip(cmd beginfillcommand(color elif command ="endfill"cmd endfillcommand( elif command ="penup"cmd penupcommand( elif command ="pendown"cmd pendowncommand(elseraise runtimeerror("unknown commandcommand self append(cmdin the code in sect the attr variable is dictionary mapping the attribute names ( keysto their associated values the child data of command node can be found by looking at the firstchild data for the node the strip method is used to strip away any unwanted blankstabsor newline characters that might appear in the string this copy belongs to 'acha