2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Utilities for XML generation/parsing.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from xml.sax.saxutils import XMLGenerator
|
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2005-07-13 09:25:57 +08:00
|
|
|
class SimplerXMLGenerator(XMLGenerator):
|
2006-06-03 21:37:34 +08:00
|
|
|
def addQuickElement(self, name, contents=None, attrs=None):
|
2005-07-13 09:25:57 +08:00
|
|
|
"Convenience method for adding an element with no children"
|
2013-10-17 16:17:41 +08:00
|
|
|
if attrs is None:
|
|
|
|
attrs = {}
|
2005-07-13 09:25:57 +08:00
|
|
|
self.startElement(name, attrs)
|
|
|
|
if contents is not None:
|
|
|
|
self.characters(contents)
|
|
|
|
self.endElement(name)
|