[XML-SIG] Getting a slice from a NodeList?

A.M. Kuchling akuchlin@cnri.reston.va.us
Thu, 14 Jan 1999 22:51:37 -0500


Michael Sanborn writes:
 > What I'm trying to do is to alter an attribute from the first two
 > members of a NodeList (called "wott_list") returned by
 > getElementsByTagName. But I don't seem to be able to get a slice of it.

The fix is to replace the __getslice__ method of the NodeList class
with this, correct, function:

    def __getslice__(self, i, j):
        userlist = NodeList([], self._document, self._parent)
        userlist.data[:] = self.data[i:j]
        return userlist

-- 
A.M. Kuchling			http://starship.skyport.net/crew/amk/
Nature is beneficent. I praise her and all her works. She is silent and wise.
She is cunning, but for good ends. She has brought me here and will also lead
me away. She may scold me, but she will not hate her work. I trust her.
    -- Goethe