Mark Murphy (a Commons Guy) wrote:
>
> RedBullet wrote:
> > I may not have this problem with the XML structure I am interested in
> > parsing, but I imagine one could run into issues if there are nested
> > elements being parsed:
> > <body>
> >      got some text here
> >      <author>me</author>
> > </body>
> >
> > I am guessing I would have to be clever and maintain multiple 
> accumulators
> > for each element when it is started (until I get the endElement).

 

> Yup. I've used stack structures for this previously, using the top of
> the stack as the StringBuilder for characters(), and pushing/popping
> StringBuilders on/off the stack in startElement()/endElement().
>
> Though my favorite approach is to use a JAR where somebody else wrote
> all that code for me... :-)
>
I've used a pointer in the 'ContentHandler' implementation that points to 
the containing element handler. I instantiate a different 'ContentHandler' 
for each 'startElement()', then follow the pointer to the containing 
element's handler upon 'endElement()' completion.

-- 
Lew
 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to