from xml.dom import minidom import xpath zooXml = """ """ mydom = minidom.parseString(zooXml) compound = xpath.findnode('/Zoo/Compound', mydom) print compound.toxml() # as expected: print xpath.find("Chimp", compound) # as expected: [] newChimp = mydom.createElement("Chimp") compound.appendChild(newChimp) print compound.toxml() # ok, two chimps now: print xpath.find("Chimp", compound) # wait a second, that's still only one chimp: [] mydom = minidom.parseString(mydom.toxml()) compound = xpath.findnode('/Zoo/Compound', mydom) print xpath.find("Chimp", compound) # now it finds both chimps: [, ] babyChimp = mydom.createElementNS(mydom.firstChild.namespaceURI, "Chimp") compound.appendChild(babyChimp) print xpath.find("Chimp", compound) # that worked: [, , ]