MCPcopy Create free account
hub / github.com/ActiveState/code / xmlElement

Class xmlElement

recipes/Python/298721_xml2obj_II/recipe-298721.py:77–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75#---------------------------------------------------------------------
76
77class xmlElement:
78
79 def __init__( self, name, parent, dictAttributes ):
80 self.data = None
81 self.name = name
82 self.parent = parent
83 self.dictAttributes = dictAttributes
84 self.listChildren = [ ]
85 self.dictData = { }
86
87
88 def __str__( self ):
89 szStr = '%s' % (self.name)
90 if self.dictAttributes:
91 szStr += "%s" % (self.dictAttributes)
92 if self.data:
93 szStr += ": %s\n" % (self.data)
94 else:
95 szStr += "\n"
96 return szStr
97
98
99 def addChild( self, node ):
100 self.listChildren.append( node )
101
102
103 def getAttribute( self, name ):
104 return self.dictAttributes[ name ]
105
106
107 def getAttributeNames( self ):
108 return self.dictAttributes.keys( )
109
110
111 def getChildren( self ):
112 return self.listChildren
113
114
115 def getData( self ):
116 return self.data
117
118
119 def getFirstChildByName( self, name ):
120 for oChild in self.iterChildrenByName( name ):
121 return oChild
122 return None
123
124
125 def getName( self ):
126 return self.name
127
128
129 def hasChildByName( self, name ):
130 for oChild in self.iterChildrenByName( name ):
131 return 1
132 return 0
133
134 def iterChildren( self ):

Callers 2

__init__Method · 0.85
startElementMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected