Wednesday, October 14, 2009

[android-developers] Re: can I get XML information step by step using SaxParser??

SaxParser "walks" through an XML file calling key events
"startElement", "endElement", and others.

You can use these events to do whatever you need at any point in the
document. So once we reach the start of <trk> we know all waypoints
have been read right?

You should call the parser in a background thread so your UI thread
can respond to a call from the parser when it reaches the marked
element.

//inside the xml handler used by Sax
public void startElement(String uri, String name, String qName,
Attributes atts) {
if (name.trim().equals("trk")){
//we have read all waypoints, we can start
acting on the data as the sax parser finishes
inTrackPoints = true;
callNotifyMethodInMainClass(wayPointArray)
}
}


For info on actually capturing the waypoints tread up on sax. it is
well covered.


On Oct 14, 6:13 am, Stefan <ebay-dah...@web.de> wrote:
> Hello,
>
> i have a big xml file and i want to use the SaxParser because i've
> read, that this is faster than DOM and XmlPullParser.
> But now I want to get some information, before the parser has read the
> whole xml-file.
>
> <?xml version="1.0" encoding="utf-8"?>
> <gpx...>
> <wpt lat="50.886021852493286" lon="6.5963780879974365">
> <desc value="Friedensstraße 1"/>
>  </wpt>
> OTHER WAYPOINTS
> ...
> ...
> <trk>
> <name>HUHU</name>
> <trkseg>
> <trkpt lat="50.88498115539551" lon="6.59727931022644"></trkpt>
> VERY MUCH TRACKPOINTS!!!
> </trkseg>
> </trk>
> <gpx>
>
> If all waypoints has been read, i want to work with that data.
> And can I told the SaxParser, that i want to read the trackpoints step
> by step (for example the first 20 trackpoints will be returned and
> then the next 20 points and so on)?
>
> Thanks,
> Stefan
>
> PS: I want/have an own class for the Handler
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate