diff options
Diffstat (limited to 'source/expatimpl.py')
-rw-r--r-- | source/expatimpl.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/expatimpl.py b/source/expatimpl.py index f9865d0..06d5375 100644 --- a/source/expatimpl.py +++ b/source/expatimpl.py @@ -55,6 +55,14 @@ class XHPParser(ParserBase): def __init__ (self, strm): ParserBase.__init__(self, strm) self.filename = None + self.ids = {} + + def startElement(self, name, attrs): + ParserBase.startElement(self, name, attrs) + if attrs.has_key('id'): + # associate this node with this ID. + val = attrs['id'] + self.ids[val] = self.nodestack[-1] def character(self, data): ParserBase.character(self, data) @@ -62,6 +70,7 @@ class XHPParser(ParserBase): # For now, I just assume that the filename element is always at the correct position. self.filename = self.char + class TreeParser(ParserBase): def __init__ (self, strm): |