[XML-SIG] DOM walker examples

Simon Pepping spepping@scaprea.hobby.nl
Fri, 26 Feb 1999 20:42:54 +0100


On Tue, Feb 23, 1999 at 08:23:11PM -0600, Kevin Russell wrote:
> """renumber.py
> A DOM-walker example: give each element a unique ID attribute
> """
> 
> from xml.dom import utils, walker
> from sys import argv
> 
> class NumberingWalker (walker.Walker):
>     counters = {}

Note that in this way counters is a class attribute, shared by all
objects. It is better to initialize it in __init__:

    def __init__(self):
        self.counters = {}

Simon Pepping
email: spepping@scaprea.hobby.nl