All pastes #778036 Raw Edit

kc5tja

public python v1 · immutable
·published 2007-11-17 06:28 UTC
rendered paste body
class XmlElement(object):    def __init__(self, typeName, content = None, attributes = None):        if content == None:            content = []        if attributes == None:            attributes = {}        self.content = content        self.attributes = attributes        self.elementName = typeName    def attributesAsXML(self):        result = ""        for a in self.attributes:            result = result + " %s=\"%s\"" % (a, self.attributes[a])        return result    def asXML(self):        result = "<%s" % self.elementName        if self.attributes:            result = result + self.attributesAsXML()        if not self.content:            return result + "/>"        else:            result = result + ">"            for c in self.contents:                result = result + c.asXML()            return result + "</%s>" % (self.elementName)