SAX Parser best practise
Hi Jan,
On 20 Sep 2005, Hummel at mpimp-golm.mpg.de wrote:
I have a question regarding best practise in setting up a XML parser within R. [snip] value="445.598999"/> (as one can see in the xml snip set)
I missed the xml snip, but I think I get the gist of your question.
I know the mechanism of using Event Handlers, as shown in the examples. But what I'm looking for is, how can I use some "path information" as mentioned in "addContext" parameter of xmlEventParse()? May somebody share a example using "addContext = TRUE" and pointing me to the variables I may use if I implement the "..." parameter within my handlers. Do I have to implement a "status machine" using some variables within my handlers, or would one prefer to use the "state" parameter of xmlEventParse()?
I'm not familiar with the addContext arg and don't know whether or not that provides another solution to your problem. I do know that you can do what you want by writing "state machine" code. I played a little with using the state arg for this purpose, but ran into some problems (sorry, no details in my memory banks). There is an example of the state approach in Bioconductor's AnnBuilder package. See R/GO.R. It isn't the prettiest or best example, but maybe it will help get you going. The general approach is to use '<<-' to reach up a level and set the state variables from inside the tag handlers. HTH, + seth