comparison emeraldtree/ElementTree.py @ 4:705fc192cd9d

Add new Node class and make it a base of Element. * emeraldtree/ElementTree.py - Add Node. - Make Node a base of Element. - Export Node. * emeraldtree/tests/test_ElementTree.py: Update.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 15:19:09 +0200
parents 34be1290ac0b
children 9b72cb3ef3c9
comparison
equal deleted inserted replaced
3:40db0b033d47 4:705fc192cd9d
85 "Comment", 85 "Comment",
86 "dump", 86 "dump",
87 "Element", "ElementTree", 87 "Element", "ElementTree",
88 "fromstring", "fromstringlist", 88 "fromstring", "fromstringlist",
89 "iselement", "iterparse", 89 "iselement", "iterparse",
90 "Node",
90 "parse", "ParseError", 91 "parse", "ParseError",
91 "PI", "ProcessingInstruction", 92 "PI", "ProcessingInstruction",
92 "QName", 93 "QName",
93 "SubElement", 94 "SubElement",
94 "tostring", "tostringlist", 95 "tostring", "tostringlist",
166 def iselement(element): 167 def iselement(element):
167 # FIXME: not sure about this; might be a better idea to look 168 # FIXME: not sure about this; might be a better idea to look
168 # for tag/attrib/text attributes 169 # for tag/attrib/text attributes
169 return isinstance(element, Element) or hasattr(element, "tag") 170 return isinstance(element, Element) or hasattr(element, "tag")
170 171
172 class Node(object):
173 """
174 Node class.
175 """
176
171 ## 177 ##
172 # Element class. This class defines the Element interface, and 178 # Element class. This class defines the Element interface, and
173 # provides a reference implementation of this interface. 179 # provides a reference implementation of this interface.
174 # <p> 180 # <p>
175 # The element name, attribute names, and attribute values can be 181 # The element name, attribute names, and attribute values can be
181 # @see Element 187 # @see Element
182 # @see SubElement 188 # @see SubElement
183 # @see Comment 189 # @see Comment
184 # @see ProcessingInstruction 190 # @see ProcessingInstruction
185 191
186 class Element(object): 192 class Element(Node):
187 # <tag attrib>text<child/>...</tag>tail 193 # <tag attrib>text<child/>...</tag>tail
188 194
189 ## 195 ##
190 # (Attribute) Element tag. 196 # (Attribute) Element tag.
191 197