def _out_tag(self, name, attrs, isLeaf):
# sorted attributes -- don't want attributes output in random order, which is what the XMLGenerator class does
self.output.write(" " * self.indent)
self.output.write("<%s" % name)
sortedNames = sorted( attrs.keys() ) # sorted list of attribute names
for name in sortedNames:
value = attrs[ name ]
# if not of type string,
if not isinstance(value, str):
# turn it into a string
value = str(value)
self.output.write(" %s=%s" % (name, quoteattr(value)))
if isLeaf:
self.output.write("/")
else:
self.indent += 4
self.output.write(">\n")
评论列表
文章目录