minixml 0.6.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
minixml/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ "Minimalist package for reading, writing, creating and editing an XML element tree."
2
+
3
+ __version__ = "0.6.3"
4
+
5
+ __all__ = ["Element", "parse", "read", "unparse", "write"]
6
+
7
+ from .element import *
8
+ from .io import *
minixml/element.py ADDED
@@ -0,0 +1,263 @@
1
+ "Element class."
2
+
3
+ __all__ = ["Element"]
4
+
5
+ import copy
6
+ from xml.sax.saxutils import quoteattr
7
+
8
+
9
+ class Element:
10
+ "XML element having a tag, attributes, parent (if any) and children (if any)."
11
+
12
+ def __init__(self, tag: str, *children, **attributes):
13
+ "The instance is initialized as a root element (i.e. it has no parent)."
14
+ if not tag:
15
+ raise ValueError("'tag' may not be empty")
16
+ self._tag = tag
17
+ self._parent = None
18
+ self._children = []
19
+ for child in children:
20
+ self.append(child)
21
+ self._attributes = {}
22
+ for name, value in attributes.items():
23
+ self[name] = value
24
+
25
+ def __str__(self):
26
+ "Return the string representation of the element's starting tag."
27
+ result = []
28
+ result.append(f"<{self.tag}")
29
+ for name, value in self._attributes.items():
30
+ result.append(f" {name}={quoteattr(value)}")
31
+ if len(self):
32
+ result.append(">")
33
+ else:
34
+ result.append("/>")
35
+ return " ".join(result)
36
+
37
+ def __getitem__(self, key):
38
+ "Get the value of the attribute in this element."
39
+ try:
40
+ return self._attributes[key]
41
+ except KeyError:
42
+ raise KeyError(f"no such attribute '{key}' in element {self}")
43
+
44
+ def __setitem__(self, key, value):
45
+ "Set the value of the attribute in this element."
46
+ if not isinstance(value, str):
47
+ value = str(value)
48
+ self._attributes[key] = value
49
+
50
+ def __delitem__(self, key):
51
+ "Delete the attribute in this element."
52
+ try:
53
+ del self._attributes[key]
54
+ except KeyError:
55
+ raise KeyError(f"no such attribute '{key}' in element {self}")
56
+
57
+ def __contains__(self, key):
58
+ "Does this element have the given attribute?"
59
+ return key in self._attributes
60
+
61
+ def __iter__(self):
62
+ "Iterate over the children of this element."
63
+ yield from self._children
64
+
65
+ def __len__(self):
66
+ "Return the number of children of this element."
67
+ return len(self._children)
68
+
69
+ def __eq__(self, other):
70
+ "Are this element and the other equal, recursively? Ignores the parent."
71
+ return not self.diff(other)
72
+
73
+ def __iadd__(self, other):
74
+ "Append the other to the end of the list of children of this other."
75
+ self.append(other)
76
+ return self
77
+
78
+ @property
79
+ def tag(self):
80
+ "Return the tag of this element; read-only."
81
+ return self._tag
82
+
83
+ @property
84
+ def parent(self):
85
+ "Return the parent, if any, of this element; read-only."
86
+ return self._parent
87
+
88
+ @property
89
+ def attributes(self):
90
+ """Return the dictionary of the attributes; read only.
91
+ This is a shallow copy of the dictionary in the instance. Changing
92
+ it will therefore not affect the attributes in the instance.
93
+ """
94
+ return self._attributes.copy()
95
+
96
+ @property
97
+ def children(self):
98
+ """Return the list of children; read only.
99
+ This is a shallow copy of the list in the instance. Changing it
100
+ will therefore not affect the list of children in the instance.
101
+ """
102
+ return list(self._children)
103
+
104
+ @property
105
+ def text(self):
106
+ """Return the text content of this element.
107
+ All children that are non-blank texts are concatenated.
108
+ """
109
+ result = []
110
+ for child in self:
111
+ if isinstance(child, str) and child.strip():
112
+ result.append(child)
113
+ return "".join(result)
114
+
115
+ @property
116
+ def root(self):
117
+ "Return the root element of this element. May be self."
118
+ result = self
119
+ while result._parent is not None:
120
+ result = result._parent
121
+ return result
122
+
123
+ @property
124
+ def depth(self):
125
+ "Depth of hierarchy for this element; number of parent steps to root."
126
+ result = 0
127
+ elem = self
128
+ while elem._parent is not None:
129
+ result += 1
130
+ elem = elem._parent
131
+ return result
132
+
133
+ def get(self, key, default=None):
134
+ "Return the value of the given attribute in this element, or the default."
135
+ try:
136
+ return self[key]
137
+ except KeyError:
138
+ return default
139
+
140
+ def set(self, key: str, value):
141
+ "Set the value of the attribute in this element."
142
+ self[key] = value
143
+
144
+ def append(self, other):
145
+ "Append the element to the end of the list of children of this element."
146
+ assert isinstance(other, (Element, str)), other
147
+ assert self is not other
148
+ if isinstance(other, Element):
149
+ if other.parent:
150
+ raise ValueError(f"element '{other}' must have no parent")
151
+ self._children.append(other)
152
+ if isinstance(other, Element):
153
+ other._parent = self
154
+
155
+ def insert(self, i: int, other):
156
+ "Insert the element at position i in the list of children of this element."
157
+ assert i >= 0 and i <= len(self)
158
+ assert isinstance(other, (Element, str)), other
159
+ assert self is not other
160
+ if isinstance(other, Element):
161
+ if other.parent:
162
+ raise ValueError(f"element '{other}' must have no parent")
163
+ self._children.insert(i, other)
164
+ if isinstance(other, Element):
165
+ other._parent = self
166
+
167
+ def replace(self, i: int, other):
168
+ """Replace the element at position i in the list of children of this element.
169
+ The replaced element is returned.
170
+ """
171
+ assert i >= 0 and i < len(self)
172
+ assert isinstance(other, (Element, str)), other
173
+ assert self is not other
174
+ if isinstance(other, Element):
175
+ if other.parent:
176
+ raise ValueError(f"element '{other}' must have no parent")
177
+ result = self._children[i]
178
+ if isinstance(result, Element):
179
+ result._parent = None
180
+ self._children[i] = other
181
+ if isinstance(other, Element):
182
+ other._parent = self
183
+ return result
184
+
185
+ def pop(self, i: [int, None]=None):
186
+ "Remove the element at position i (last if None) and return it."
187
+ assert i is None or (i >= 0 and i < len(self))
188
+ if i is None:
189
+ result = self._children.pop()
190
+ else:
191
+ result = self._children.pop(i)
192
+ result._parent = None
193
+ return result
194
+
195
+ def free(self):
196
+ "Remove this element from its parent, if any. Return itself."
197
+ if self._parent is not None:
198
+ self._parent._children.remove(self)
199
+ self._parent = None
200
+ return self
201
+
202
+ def create(self, tag, **attributes):
203
+ """Create an element with the given tag and attributes,
204
+ and append to the children of this element.
205
+ Return the created element.
206
+ """
207
+ # Ensure that the same class is used throughout.
208
+ elem = self.__class__(tag, **attributes)
209
+ self.append(elem)
210
+ return elem
211
+
212
+ def copy(self):
213
+ """Make a copy of this element and its children (i.e. deepcopy).
214
+ The returned copy element has no parent.
215
+ """
216
+ result = copy.deepcopy(self)
217
+ result._parent = None
218
+ result._set_parent()
219
+ return result
220
+
221
+ def _set_parent(self):
222
+ "Set the correct parent for all children recursively."
223
+ for child in self:
224
+ if isinstance(child, Element):
225
+ child._parent = self
226
+ child._set_parent()
227
+
228
+ def walk(self, test=None):
229
+ """Walk over this element and all its Element children recursively,
230
+ yielding those elements that match the given test function.
231
+ If no test function given, yield all.
232
+ NOTE: The test function must handle both Element instances and strings.
233
+ """
234
+ if test is not None and not callable(test):
235
+ raise ValueError("'test' for method 'walk' must be a callable or None")
236
+ if test is None or test(self):
237
+ yield self
238
+ for child in self:
239
+ if isinstance(child, Element):
240
+ yield from child.walk(test=test)
241
+ elif test is None or test(child):
242
+ yield child
243
+
244
+ def diff(self, other):
245
+ """Return the first difference between this element and the other, recursively.
246
+ Ignores the parents of this element and the other.
247
+ Return a tuple describing the difference, or None.
248
+ """
249
+ if not isinstance(other, self.__class__):
250
+ return ("instance", self, other)
251
+ if self.tag != other.tag:
252
+ return ("tag", self, other)
253
+ if self._attributes != other.attributes:
254
+ return ("attributes", self, other)
255
+ if len(self) != len(other):
256
+ return ("len", self, other)
257
+ for child1, child2 in zip(self._children, other.children):
258
+ if isinstance(child1, Element):
259
+ if result := child1.diff(child2):
260
+ return result
261
+ elif child1 != child2:
262
+ return ("diff", child1, child2)
263
+ return None
minixml/io.py ADDED
@@ -0,0 +1,104 @@
1
+ "Parse XML code into an Element tree, and unparse an Element tree into XML code."
2
+
3
+ __all__ = ["parse", "read", "unparse", "write"]
4
+
5
+
6
+ import io
7
+ import xml.sax
8
+ from xml.sax.saxutils import quoteattr, escape, unescape
9
+
10
+ from .element import Element
11
+
12
+
13
+ def parse(content, element_class=Element):
14
+ "Parse the given XML content (string). Return the root XML element."
15
+ return read(io.StringIO(content), element_class=element_class)
16
+
17
+
18
+ def read(filepath_or_stream, element_class=Element):
19
+ """Read and parse the file given by its path, or the open file object.
20
+ Return the root Element.
21
+ """
22
+ content_handler = ContentHandler(element_class=element_class)
23
+ try:
24
+ xml.sax.parse(filepath_or_stream, content_handler)
25
+ except xml.sax.SAXException as error:
26
+ raise ValueError(f"XML parse error: {error}")
27
+ return content_handler.root
28
+
29
+
30
+ def unparse(element, indent=0, decl='<?xml version="1.0" encoding="utf-8"?>'):
31
+ """Return the XML code for the element and its children as a string.
32
+ 'indent' is the number of blanks to use for each indentation level.
33
+ The 'decl' value is output first if it is a non-empty string.
34
+ """
35
+ assert isinstance(indent, int) and indent >= 0
36
+ outfile = io.StringIO()
37
+ write(outfile, element, indent=indent, decl=decl)
38
+ return outfile.getvalue()
39
+
40
+
41
+ def write(outfile, element, indent=0, decl='<?xml version="1.0" encoding="utf-8"?>'):
42
+ """Write the XML of the element and its children into the open file object.
43
+ The 'decl' value is output first if it is a non-empty string.
44
+ """
45
+ assert isinstance(indent, int) and indent >= 0
46
+ if decl:
47
+ outfile.write(decl + "\n")
48
+ _write(outfile, element, "", indent)
49
+
50
+
51
+ def _write(outfile, element, padding, indent):
52
+ "Recursively write out the element and its children."
53
+ outfile.write(padding)
54
+ outfile.write(f"<{element.tag}")
55
+ for name, value in element.attributes.items():
56
+ outfile.write(f" {name}={quoteattr(value)}")
57
+ if len(element):
58
+ outfile.write(">")
59
+ newline = False
60
+ for elem in element:
61
+ if isinstance(elem, Element):
62
+ if indent:
63
+ outfile.write("\n")
64
+ newline = True
65
+ _write(outfile, elem, padding + " " * indent, indent)
66
+ elif isinstance(elem, str):
67
+ outfile.write(escape(elem))
68
+ newline = False
69
+ else:
70
+ outfile.write(escape(str(elem)))
71
+ newline = False
72
+ if newline:
73
+ if indent:
74
+ outfile.write("\n")
75
+ outfile.write(padding)
76
+ outfile.write(f"</{element.tag}>")
77
+ else:
78
+ outfile.write("/>")
79
+
80
+
81
+ class ContentHandler(xml.sax.ContentHandler):
82
+ "Handle XML SAX parse events, turning them into an Element tree."
83
+
84
+ def __init__(self, element_class=Element):
85
+ assert issubclass(element_class, Element)
86
+ self.element_class = element_class
87
+ self.stack = []
88
+ self.root = None
89
+
90
+ def startElement(self, tag: str, attributes):
91
+ elem = self.element_class(tag, **dict(attributes))
92
+ if self.stack:
93
+ self.stack[-1]._children.append(elem)
94
+ elem._parent = self.stack[-1]
95
+ else:
96
+ self.root = elem
97
+ self.stack.append(elem)
98
+
99
+ def endElement(self, tag: str):
100
+ self.stack.pop()
101
+
102
+ def characters(self, content: str):
103
+ if content := content.strip():
104
+ self.stack[-1]._children.append(unescape(content))
minixml/py.typed ADDED
File without changes
@@ -0,0 +1,466 @@
1
+ Metadata-Version: 2.3
2
+ Name: minixml
3
+ Version: 0.6.3
4
+ Summary: Minimalist module for reading, writing, creating and editing an XML element tree.
5
+ Author: Per Kraulis
6
+ Author-email: Per Kraulis <per.kraulis@gmail.com>
7
+ Requires-Python: >=3.14
8
+ Description-Content-Type: text/markdown
9
+
10
+ # minixml
11
+
12
+ Minimalist module for reading, writing, creating and editing an XML element tree.
13
+
14
+ This code has been lovingly hand-crafted. No AI tools were used in its development.
15
+
16
+ # Software
17
+
18
+ There are no dependencies except for the standard Python library.
19
+
20
+ # Usage
21
+
22
+ ```python
23
+ import minixml
24
+
25
+ # The root element.
26
+ svg = minixml.Element("svg", width=320, height=130, xmlns="http://www.w3.org/2000/svg")
27
+
28
+ # A child element can be created from the parent.
29
+ # It is automatically appended to it as a child.
30
+ svg.create(
31
+ "rect",
32
+ width=300,
33
+ height=100,
34
+ x=10,
35
+ y=10,
36
+ style="fill:rgb(0,0,255);stroke-width:3;stroke:red",
37
+ )
38
+
39
+ # An element can also be created from scratch and subsequently appended.
40
+ t = minixml.Element("text", x=5, y=15, fill="red")
41
+ t.append("I love SVG!")
42
+ svg.append(t)
43
+
44
+ # Serialize the Element tree into XML code; the XML declaration is prepended.
45
+ xmlcode = minixml.unparse(svg, indent=2)
46
+
47
+ # Ensure that unparse and parse are symmetric functions.
48
+ svg2 = minixml.parse(xmlcode)
49
+ assert svg == svg2
50
+
51
+ # Display the result.
52
+ print(xmlcode)
53
+ ```
54
+
55
+ Produces:
56
+
57
+ ```svg
58
+ <?xml version="1.0" encoding="utf-8"?>
59
+ <svg width="320" height="130" xmlns="http://www.w3.org/2000/svg">
60
+ <rect width="300" height="100" x="10" y="10" style="fill:rgb(0,0,255);stroke-width:3;stroke:red"/>
61
+ <text x="5" y="15" fill="red">I love SVG!</text>
62
+ </svg>
63
+ ```
64
+
65
+ # API
66
+
67
+ The `minixml` namespace contains the features most client software will need:
68
+
69
+ * [Element](#element-objects) (class)
70
+ * [parse](#parse) (function)
71
+ * [read](#read) (function)
72
+ * [unparse](#unparse) (function)
73
+ * [write](#write) (function)
74
+
75
+ These have been imported from `minixml.element` and `minixml.io`, which in most
76
+ cases will not need to be used directly by client software.
77
+
78
+ The following was produced using **pydoc-markdown**
79
+ https://github.com/NiklasRosenstein/pydoc-markdown
80
+
81
+ <a id="minixml"></a>
82
+
83
+ # minixml
84
+
85
+ Minimalist package for reading, writing, creating and editing an XML element tree.
86
+
87
+ <a id="minixml.element"></a>
88
+
89
+ # minixml.element
90
+
91
+ Element class.
92
+
93
+ <a id="minixml.element.Element"></a>
94
+
95
+ ## Element Objects
96
+
97
+ ```python
98
+ class Element()
99
+ ```
100
+
101
+ XML element having a tag, attributes, parent (if any) and children (if any).
102
+
103
+ <a id="minixml.element.Element.__init__"></a>
104
+
105
+ #### \_\_init\_\_
106
+
107
+ ```python
108
+ def __init__(tag: str, *children, **attributes)
109
+ ```
110
+
111
+ The instance is initialized as a root element (i.e. it has no parent).
112
+
113
+ <a id="minixml.element.Element.__str__"></a>
114
+
115
+ #### \_\_str\_\_
116
+
117
+ ```python
118
+ def __str__()
119
+ ```
120
+
121
+ Return the string representation of the element's starting tag.
122
+
123
+ <a id="minixml.element.Element.__getitem__"></a>
124
+
125
+ #### \_\_getitem\_\_
126
+
127
+ ```python
128
+ def __getitem__(key)
129
+ ```
130
+
131
+ Get the value of the attribute in this element.
132
+
133
+ <a id="minixml.element.Element.__setitem__"></a>
134
+
135
+ #### \_\_setitem\_\_
136
+
137
+ ```python
138
+ def __setitem__(key, value)
139
+ ```
140
+
141
+ Set the value of the attribute in this element.
142
+
143
+ <a id="minixml.element.Element.__delitem__"></a>
144
+
145
+ #### \_\_delitem\_\_
146
+
147
+ ```python
148
+ def __delitem__(key)
149
+ ```
150
+
151
+ Delete the attribute in this element.
152
+
153
+ <a id="minixml.element.Element.__contains__"></a>
154
+
155
+ #### \_\_contains\_\_
156
+
157
+ ```python
158
+ def __contains__(key)
159
+ ```
160
+
161
+ Does this element have the given attribute?
162
+
163
+ <a id="minixml.element.Element.__iter__"></a>
164
+
165
+ #### \_\_iter\_\_
166
+
167
+ ```python
168
+ def __iter__()
169
+ ```
170
+
171
+ Iterate over the children of this element.
172
+
173
+ <a id="minixml.element.Element.__len__"></a>
174
+
175
+ #### \_\_len\_\_
176
+
177
+ ```python
178
+ def __len__()
179
+ ```
180
+
181
+ Return the number of children of this element.
182
+
183
+ <a id="minixml.element.Element.__eq__"></a>
184
+
185
+ #### \_\_eq\_\_
186
+
187
+ ```python
188
+ def __eq__(other)
189
+ ```
190
+
191
+ Are this element and the other equal, recursively? Ignores the parent.
192
+
193
+ <a id="minixml.element.Element.__iadd__"></a>
194
+
195
+ #### \_\_iadd\_\_
196
+
197
+ ```python
198
+ def __iadd__(other)
199
+ ```
200
+
201
+ Append the other to the end of the list of children of this other.
202
+
203
+ <a id="minixml.element.Element.tag"></a>
204
+
205
+ #### tag
206
+
207
+ ```python
208
+ @property
209
+ def tag()
210
+ ```
211
+
212
+ Return the tag of this element; read-only.
213
+
214
+ <a id="minixml.element.Element.parent"></a>
215
+
216
+ #### parent
217
+
218
+ ```python
219
+ @property
220
+ def parent()
221
+ ```
222
+
223
+ Return the parent, if any, of this element; read-only.
224
+
225
+ <a id="minixml.element.Element.attributes"></a>
226
+
227
+ #### attributes
228
+
229
+ ```python
230
+ @property
231
+ def attributes()
232
+ ```
233
+
234
+ Return the dictionary of the attributes; read only.
235
+ This is a shallow copy of the dictionary in the instance. Changing
236
+ it will therefore not affect the attributes in the instance.
237
+
238
+ <a id="minixml.element.Element.children"></a>
239
+
240
+ #### children
241
+
242
+ ```python
243
+ @property
244
+ def children()
245
+ ```
246
+
247
+ Return the list of children; read only.
248
+ This is a shallow copy of the list in the instance. Changing it
249
+ will therefore not affect the list of children in the instance.
250
+
251
+ <a id="minixml.element.Element.text"></a>
252
+
253
+ #### text
254
+
255
+ ```python
256
+ @property
257
+ def text()
258
+ ```
259
+
260
+ Return the text content of this element.
261
+ All children that are non-blank texts are concatenated.
262
+
263
+ <a id="minixml.element.Element.root"></a>
264
+
265
+ #### root
266
+
267
+ ```python
268
+ @property
269
+ def root()
270
+ ```
271
+
272
+ Return the root element of this element. May be self.
273
+
274
+ <a id="minixml.element.Element.depth"></a>
275
+
276
+ #### depth
277
+
278
+ ```python
279
+ @property
280
+ def depth()
281
+ ```
282
+
283
+ Depth of hierarchy for this element; number of parent steps to root.
284
+
285
+ <a id="minixml.element.Element.get"></a>
286
+
287
+ #### get
288
+
289
+ ```python
290
+ def get(key, default=None)
291
+ ```
292
+
293
+ Return the value of the given attribute in this element, or the default.
294
+
295
+ <a id="minixml.element.Element.set"></a>
296
+
297
+ #### set
298
+
299
+ ```python
300
+ def set(key: str, value)
301
+ ```
302
+
303
+ Set the value of the attribute in this element.
304
+
305
+ <a id="minixml.element.Element.append"></a>
306
+
307
+ #### append
308
+
309
+ ```python
310
+ def append(other)
311
+ ```
312
+
313
+ Append the element to the end of the list of children of this element.
314
+
315
+ <a id="minixml.element.Element.insert"></a>
316
+
317
+ #### insert
318
+
319
+ ```python
320
+ def insert(i: int, other)
321
+ ```
322
+
323
+ Insert the element at position i in the list of children of this element.
324
+
325
+ <a id="minixml.element.Element.replace"></a>
326
+
327
+ #### replace
328
+
329
+ ```python
330
+ def replace(i: int, other)
331
+ ```
332
+
333
+ Replace the element at position i in the list of children of this element.
334
+ The replaced element is returned.
335
+
336
+ <a id="minixml.element.Element.pop"></a>
337
+
338
+ #### pop
339
+
340
+ ```python
341
+ def pop(i: [int, None] = None)
342
+ ```
343
+
344
+ Remove the element at position i (last if None) and return it.
345
+
346
+ <a id="minixml.element.Element.free"></a>
347
+
348
+ #### free
349
+
350
+ ```python
351
+ def free()
352
+ ```
353
+
354
+ Remove this element from its parent, if any. Return itself.
355
+
356
+ <a id="minixml.element.Element.create"></a>
357
+
358
+ #### create
359
+
360
+ ```python
361
+ def create(tag, **attributes)
362
+ ```
363
+
364
+ Create an element with the given tag and attributes,
365
+ and append to the children of this element.
366
+ Return the created element.
367
+
368
+ <a id="minixml.element.Element.copy"></a>
369
+
370
+ #### copy
371
+
372
+ ```python
373
+ def copy()
374
+ ```
375
+
376
+ Make a copy of this element and its children (i.e. deepcopy).
377
+ The returned copy element has no parent.
378
+
379
+ <a id="minixml.element.Element.walk"></a>
380
+
381
+ #### walk
382
+
383
+ ```python
384
+ def walk(test=None)
385
+ ```
386
+
387
+ Walk over this element and all its Element children recursively,
388
+ yielding those elements that match the given test function.
389
+ If no test function given, yield all.
390
+ NOTE: The test function must handle both Element instances and strings.
391
+
392
+ <a id="minixml.element.Element.diff"></a>
393
+
394
+ #### diff
395
+
396
+ ```python
397
+ def diff(other)
398
+ ```
399
+
400
+ Return the first difference between this element and the other, recursively.
401
+ Ignores the parents of this element and the other.
402
+ Return a tuple describing the difference, or None.
403
+
404
+ <a id="minixml.io"></a>
405
+
406
+ # minixml.io
407
+
408
+ Parse XML code into an Element tree, and unparse an Element tree into XML code.
409
+
410
+ <a id="minixml.io.parse"></a>
411
+
412
+ #### parse
413
+
414
+ ```python
415
+ def parse(content, element_class=Element)
416
+ ```
417
+
418
+ Parse the given XML content (string). Return the root XML element.
419
+
420
+ <a id="minixml.io.read"></a>
421
+
422
+ #### read
423
+
424
+ ```python
425
+ def read(filepath_or_stream, element_class=Element)
426
+ ```
427
+
428
+ Read and parse the file given by its path, or the open file object.
429
+ Return the root Element.
430
+
431
+ <a id="minixml.io.unparse"></a>
432
+
433
+ #### unparse
434
+
435
+ ```python
436
+ def unparse(element, indent=0, decl='<?xml version="1.0" encoding="utf-8"?>')
437
+ ```
438
+
439
+ Return the XML code for the element and its children as a string.
440
+ 'indent' is the number of blanks to use for each indentation level.
441
+ The 'decl' value is output first if it is a non-empty string.
442
+
443
+ <a id="minixml.io.write"></a>
444
+
445
+ #### write
446
+
447
+ ```python
448
+ def write(outfile,
449
+ element,
450
+ indent=0,
451
+ decl='<?xml version="1.0" encoding="utf-8"?>')
452
+ ```
453
+
454
+ Write the XML of the element and its children into the open file object.
455
+ The 'decl' value is output first if it is a non-empty string.
456
+
457
+ <a id="minixml.io.ContentHandler"></a>
458
+
459
+ ## ContentHandler Objects
460
+
461
+ ```python
462
+ class ContentHandler(xml.sax.ContentHandler)
463
+ ```
464
+
465
+ Handle XML SAX parse events, turning them into an Element tree.
466
+
@@ -0,0 +1,7 @@
1
+ minixml/__init__.py,sha256=87MAJ0otqPeoqR1_-F7GcRglhidnkpdWkB3lD3arZcs,210
2
+ minixml/element.py,sha256=D_IhRwrH7BQH-4IT40Ne-JCZ-mcW9JRizqZMHFwgyno,9056
3
+ minixml/io.py,sha256=hCl_nKSGJcBmGToutAYwqXoDD0aSPCBFn9YMxZBP4Uk,3513
4
+ minixml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ minixml-0.6.3.dist-info/WHEEL,sha256=VOHKyukui3UMeyUkkBf5F7N5xN_6X6W7zHVvalNVVvI,81
6
+ minixml-0.6.3.dist-info/METADATA,sha256=lGdK6eC61ngtApoXdnPpC55wbk8dd000rcTnnFI91hk,8900
7
+ minixml-0.6.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.12.21
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any