from xml.parsers import expatxmlFile = "emails.xml"#Define a class that will store the character dataclass xmlText(object): def __init__ (self): self.textBuff = "" def CharacterData(self, data): data = data.strip() if data: data = data.encode('ascii') self.textBuff += data + "n" def Parse(self, fName): xmlParser = expat.ParserCreate() xmlParser.CharacterDataHandler = self.CharacterData xmlParser.Parse(open(fName).read(), 1)xText = xmlText()xText.Parse(xmlFile)print "Text from %sn=" % xmlFileprint xText.textBuff
Name (required)
email (will not be published) (required)
Website