I have a relatively general question regarding SAX. I understand how it works, and based on tutorials I’ve read, I’ve learned to keep the state by having a ton of data members like inNode that are booleans and then in each event handler, check each boolean and handle the parameters accordingly.
To me, this seems really inefficient, is there more efficient way or is that just the nature of SAX?
Thanks,
Chris
Often, you can keep state by having a simple stack of tags.
When you enter a node, you push.
When you leave a node, you pop.
Sometimes this is better than a lot of booleans. Instead, you examine the stack to see if the correct context is in place to preserve the data being parsed.