Caching Node Lookups : XML Children Node « XML « Python






Caching Node Lookups

def loadGrammar(self, grammar): 
    self.grammar = self._load(grammar) 
    self.refs = {}                                 
    for ref in self.grammar.getElementsByTagName("ref"):     
        self.refs[ref.attributes["id"].value] = ref          

           
       








Related examples in the same category

1.Getting Child Nodes
2.toxml Works on Any Nodetoxml Works on Any Node
3.Child Nodes Can Be TextChild Nodes Can Be Text
4.Finding the Direct Children of a Node