data argument in XML node listeners
![](https://secure.gravatar.com/avatar/25e99dc116970ba9f94972e272149acd.jpg?s=120&d=mm&r=g)
Is the void* data argument in XML node listeners available to pass extra data to listener callback routines, or does it have another function that would prevent that purpose? (For example, passing a pointer to an instance of a class that is unique on a per-document basis.)
I've been reading the listener and DOM tree implementation and it seems that this is correct, but I just wanted to make sure.
-- David
![](https://secure.gravatar.com/avatar/15f5e6abf26f57e1838c29a8356ce7f8.jpg?s=120&d=mm&r=g)
Quoting David Yip <yipdw@...635...>:
Is the void* data argument in XML node listeners available to pass extra data to listener callback routines, or does it have another function that would prevent that purpose? (For example, passing a pointer to an instance of a class that is unique on a per-document basis.)
Yes, you can do that, but I would strongly recommend using XML::Node::addObserver rather than XML::Node::addListener in new code.
XML::Node::addListener is effectively just a wrapper around XML::Node::addObserver, and will be going away after the 0.42 release.
Simply subclass XML::NodeObserver and override the notify*() methods for any events you are interested in. You can keep any needed supplemental data in data memebrs of your subclass.
-mental
![](https://secure.gravatar.com/avatar/25e99dc116970ba9f94972e272149acd.jpg?s=120&d=mm&r=g)
Oh, cool -- that will make things much easier. Thanks!
-- David
On Friday 08 July 2005 01:23 pm, mental@...3... wrote:
Yes, you can do that, but I would strongly recommend using XML::Node::addObserver rather than XML::Node::addListener in new code.
XML::Node::addListener is effectively just a wrapper around XML::Node::addObserver, and will be going away after the 0.42 release.
Simply subclass XML::NodeObserver and override the notify*() methods for any events you are interested in. You can keep any needed supplemental data in data memebrs of your subclass.
-mental
participants (2)
-
unknown@example.com
-
David Yip