File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232import xml .dom
3333_Node = xml .dom .Node
3434
35+
36+ if list is type ([]):
37+ class NodeList (list ):
38+ def item (self , index ):
39+ if 0 <= index < len (self ):
40+ return self [index ]
41+
42+ def __getattr__ (self , name ):
43+ if name == "length" :
44+ return len (self )
45+ raise AttributeError , name
46+
47+ else :
48+ def NodeList ():
49+ return []
50+
51+
3552class Node (_Node ):
3653 allnodes = {}
3754 _debug = 0
@@ -41,7 +58,7 @@ class Node(_Node):
4158 namespaceURI = None # this is non-null only for elements and attributes
4259
4360 def __init__ (self ):
44- self .childNodes = []
61+ self .childNodes = NodeList ()
4562 self .parentNode = self .ownerDocument = None
4663 if Node ._debug :
4764 index = repr (id (self )) + repr (self .__class__ )
@@ -234,7 +251,7 @@ def cloneNode(self, deep):
234251 clone = new .instance (self .__class__ , self .__dict__ .copy ())
235252 if self ._makeParentNodes :
236253 clone .parentNode = None
237- clone .childNodes = []
254+ clone .childNodes = NodeList ()
238255 if deep :
239256 for child in self .childNodes :
240257 clone .appendChild (child .cloneNode (1 ))
You can’t perform that action at this time.
0 commit comments