xmlutils.py 453 B

12345678910111213141516
  1. """
  2. Utilities for XML generation/parsing.
  3. """
  4. from xml.sax.saxutils import XMLGenerator
  5. class SimplerXMLGenerator(XMLGenerator):
  6. def addQuickElement(self, name, contents=None, attrs=None):
  7. "Convenience method for adding an element with no children"
  8. if attrs is None:
  9. attrs = {}
  10. self.startElement(name, attrs)
  11. if contents is not None:
  12. self.characters(contents)
  13. self.endElement(name)