In django,
addQuickElement(name,content,attr)
generates XML like this
<name attr="attr">content</name>
While I want to generate
<name attr="attr" />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just don’t specify the
contentsargument.For reference, this is
django/utils/xmlutils.py:You can see here that you just need to not specify
contents, and so you can dox.addQuickElement(name, attrs=attrs).(A quick look at XMLGenerator indicates this will still produce an end-tag, rather than a self-closing tag. In Python 3.2 an argument
short_empty_elementswas added toXMLGenerator.__init__, but Django isn’t still only compatible with Python 2.x. If you care about getting short tags, take a look at thexml.sax.saxutils.XMLGenerator.startElementimplementation.)