-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml_document_parts.py
46 lines (37 loc) · 950 Bytes
/
xml_document_parts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Attribute:
"""
class for objects that represent some key-value pair
for an Element's attributes.
Attributes:
----------
- key (str):
Attribute key.
- value (str):
Attribute value.
"""
def __init__(self, key, value):
self.key = key
self.value = value
class Element:
"""
class for objects that represent some element (tag) in an
XML file.
Attributes:
----------
- name (str):
Element/tag name.
- children (list of Element obj):
Element's children.
- parent (Element):
Element's parent.
- attributes (list of Attribute obj):
Element's attributes.
- content (str):
Element's text content.
"""
def __init__(self, name, parent, attributes):
self.name = name
self.children = []
self.parent = parent
self.attributes = attributes
self.content = ""