I've done quite a bit of XML parsing in my current app and this is this example helped a lot .
Design wise i believe instead of toasts or intent broadcasting etc you should be using a custom SAX Handler which will instantiate a Parse object at the beginning XML element. This object is a representation of your XML items. So maybe the object will be Car and have a setter/getter for Door, Colour, Wheels. As your parsing the data in the SAX parser you will set those values. when the SAX parser finishes parsing you call your parser to have it pass back the object to your activity which is full with all cars from your XML. In my case i actually populate a list/array of my objects which are passed back. The example only deals with one set of data. Anyway that link explains it all.
Edit: Was just looking at my code, actually what I do in my handler is build an array of my ParsedData set objects which are passed back to the activity after parsing is complete via getParsedData(). Here is some of the important code:
XML handler:
private boolean in_IdSite;
private boolean in_SiteName;
private ArrayList<ParsedChannelDataSet> list = new ArrayList<ParsedChannelDataSet>();
public ArrayList<ParsedChannelDataSet> getParsedData() {
return this.list;
}
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
// first tag parsed so add a new ParsedEventDataSet object
if(localName.equals("stmSiteUser")) {
list.add(new ParsedChannelDataSet());
} else if (localName.equals("idSite")) {
this.in_IdSite = true;
} else if (localName.equals("siteName")) {
this.in_SiteName = true;
}
}
@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
if (localName.equals("idSite")) {
this.in_IdSite = false;
} else if (localName.equals("siteName")) {
this.in_SiteName = false;
}
}
@Override
public void characters(char ch[], int start, int length) {
// determine if any tag is current, get data from tag and populate into ParsedEventDataSet
if (this.in_IdSite) {
this.list.get(this.list.size()-1).setExtractedIdSite(new String(ch, start, length));
} else if (this.in_SiteName) {
this.list.get(this.list.size()-1).setExtractedSiteName(new String(ch, start, length));
}
}
Here is my sample ParsedDataSampleSet (this can be called whatever you want) obviously you want to replace siteName and idSite with something else too. These are just my XML elements
public class ParsedChannelDataSet {
private String extractedIdSite = null;
private String extractedSiteName = null;
public String getExtractedIdSite() {
return extractedIdSite;
}
public void setExtractedIdSite(String _extractedIdSite) {
this.extractedIdSite = _extractedIdSite;
}
public String getExtractedSiteName() {
return extractedSiteName;
}
public void setExtractedSiteName(String _extractedSiteName) {
Log.d("", _extractedSiteName);
this.extractedSiteName = _extractedSiteName;
}
public String toString() {
/* TODO */
return "todo";
}
}
So you can see I build an array of ParsedChannelDataSet objects which are passed back to the activity. this is a far better solution than using toast or broadcasts because its a more decoupled solution
Edit 2: The first post on this 2nd page of the site I linked mentions about parsing multiple XML elements like mine. See here (parse multiple xml elements).
I hope this helps you out