Make Android XML reader only read part of the XML file
I'm making an app that gets most of it's information from an XML file. I have been using an RSS-like XML, but now I've found an XML with much more information that I want to use. I already have the XML reader working, but when I put the XML into my code, it returns with "NO DATA", which i开发者_如何学运维s what I told it to do if it can't get any data from the XML. I've tried to find ways to make the app only read the part of the XML, but I haven't found a way that works yet.
This is the XML I am trying to read. http://www.supercross.com/mobileapps/supercross.xml (You might have to view source to see the XML)
Use SAX to parse the file, and only handle the events you want to handle.
Is this the standard size of your xmls. If the size is not huge, then I recommend that you use DOM Api. Your code will be simpler. Code samples available in the following link.
If your xml is of considerable size, then you need to use SAX, like the previous answer. It is event based and not as elegant, but has lesser memory footprint. ( Especially since its a device).
Code Samples.
精彩评论