def nonEmptyTag(self, obj): attrs = {} for assoc in obj.value(): attrs[assoc.nameOf()] = assoc.value() self.doc_handler.startElement(obj.nameOf(), saxutils.AttributeMap(attrs))
def unknown_starttag(self, tag, attributes): "Handles start tags." attrs = {} for (a, v) in attributes: attrs[a] = v self.doc_handler.startElement(tag, saxutils.AttributeMap(attrs))
def startElement(self,name,attrs): at = {} # Backward compatibility code, for older versions of the # PyExpat module if type(attrs) == type({}): at = attrs else: # Assume it's a list containing alternating names & values at = {} for i in range(0, len(attrs), 2): at[attrs[i]] = attrs[i+1] self.doc_handler.startElement(name,saxutils.AttributeMap(at))
def finish_starttag(self, name, attrs): self._nesting = self._nesting + 1 self.doc_handler.startElement(name, saxutils.AttributeMap(attrs))
def unknown_starttag(self, tag, attributes): tag = unicode(tag, self.encoding) newattr = {} for k, v in attributes.items(): newattr[unicode(k, self.encoding)] = unicode(v, self.encoding) self.doc_handler.startElement(tag, saxutils.AttributeMap(newattr))