Revision 304
Added by Aaron Marcuse-Kubitza about 13 years ago
lib/xml_dom.py | ||
---|---|---|
126 | 126 |
def create_doc(root='_'): |
127 | 127 |
return minidom.getDOMImplementation().createDocument(None, root, None) |
128 | 128 |
|
129 |
prettyxml_config = dict(addindent=' ', newl='\n') |
|
130 |
|
|
129 | 131 |
# minidom modifications |
130 | 132 |
|
131 | 133 |
minidom._write_data = lambda writer, data: writer.write(escape(data)) |
132 | 134 |
|
133 | 135 |
minidom.Node.__str__ = lambda self: self.toxml() |
134 | 136 |
|
135 |
def __Node_writeprettyxml(self, writer, indent='', addindent=' ', newl='\n'): |
|
136 |
self.writexml(writer, indent, addindent, newl) |
|
137 |
minidom.Node.writeprettyxml = __Node_writeprettyxml |
|
138 |
|
|
139 | 137 |
def __Element_write_opening(self, writer, indent='', addindent='', newl=''): |
140 | 138 |
writer.write(indent+'<'+self.tagName) |
141 | 139 |
for attr_idx in xrange(self.attributes.length): |
bin/map | ||
---|---|---|
167 | 167 |
def use_row(root): pass # TODO: implement this |
168 | 168 |
output = sys.stdout |
169 | 169 |
doc1 = get_xml(use_row) |
170 |
doc1.writeprettyxml(output)
|
|
170 |
doc1.writexml(output, **xml_dom.prettyxml_config)
|
|
171 | 171 |
|
172 | 172 |
try: main() |
173 | 173 |
except Parser.SyntaxException, e: raise SystemExit(str(e)) |
Also available in: Unified diff
Use new xml_dom.prettyxml_config instead of Node.writeprettyxml because it can be passed as keyword args to any writexml function