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

Method StartElement

recipes/Python/149368_xml2obj/recipe-149368.py:52–63  ·  view source on GitHub ↗

SAX start element even handler

(self,name,attributes)

Source from the content-addressed store, hash-verified

50 self.nodeStack = []
51
52 def StartElement(self,name,attributes):
53 'SAX start element even handler'
54 # Instantiate an Element object
55 element = Element(name.encode(),attributes)
56
57 # Push element onto the stack and make it a child of parent
58 if len(self.nodeStack) > 0:
59 parent = self.nodeStack[-1]
60 parent.AddChild(element)
61 else:
62 self.root = element
63 self.nodeStack.append(element)
64
65 def EndElement(self,name):
66 'SAX end element event handler'

Callers

nothing calls this directly

Calls 4

AddChildMethod · 0.80
ElementClass · 0.70
encodeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected