Revision 774
Added by Aaron Marcuse-Kubitza almost 13 years ago
xml_dom.py | ||
---|---|---|
190 | 190 |
|
191 | 191 |
minidom.Node.__iter__ = lambda self: NodeIter(self) |
192 | 192 |
|
193 |
def __Node_str(self): |
|
194 |
if is_simple(self): return self.toxml() |
|
195 |
else: return self.toprettyxml(**toprettyxml_config) |
|
196 |
minidom.Node.__str__ = __Node_str |
|
193 |
minidom.Node.__str__ = lambda self: self.toxml() |
|
197 | 194 |
|
198 | 195 |
minidom.Node.pop = lambda self: self.removeChild(self.lastChild) |
199 | 196 |
|
... | ... | |
216 | 213 |
_writexml_orig = minidom.Element.writexml |
217 | 214 |
def __Element_writexml(self, writer, indent='', addindent='', newl=''): |
218 | 215 |
if isinstance(indent, int): indent = addindent*indent |
219 |
if is_text(self):
|
|
220 |
self.write_opening(writer, indent, addindent, '') # no newline
|
|
221 |
writer.write(escape(value(self)))
|
|
222 |
self.write_closing(writer, indent, addindent, newl)
|
|
216 |
if is_simple(self):
|
|
217 |
writer.write(indent)
|
|
218 |
_writexml_orig(self, writer)
|
|
219 |
writer.write(newl)
|
|
223 | 220 |
else: _writexml_orig(self, writer, indent, addindent, newl) |
224 | 221 |
minidom.Element.writexml = __Element_writexml |
225 | 222 |
|
Also available in: Unified diff
xml_dom.py: Print simple XML elements on one line