Back to project page SELP2013.
The source code is released under:
License ======= This work is licensed under the BSD 2-clause license as follows. # BSD 2-clause license Copyright (c) 2013, Sky Welch All rights reserved. Redistribution and use in source and ...
If you think the Android project SELP2013 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.skywelch.selp2013; /*from w w w. j av a2s .c o m*/ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import android.util.Xml; public class VenuesXmlParser { private static final String ns = null; public ArrayList<Venue> parse(InputStream in) throws XmlPullParserException, IOException { try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(in, null); parser.nextTag(); return readFeed(parser); } finally { in.close(); } } private ArrayList<Venue> readFeed(XmlPullParser parser) throws XmlPullParserException, IOException { ArrayList<Venue> entries = new ArrayList<Venue>(); parser.require(XmlPullParser.START_TAG, ns, "venues"); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if (name.equals("building")) { entries.add(readEntry(parser)); } else { XMLUtilities.skip(parser); } } return entries; } private Venue readEntry(XmlPullParser parser) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, ns, "building"); String name = ""; String description = ""; String map = ""; while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String tag = parser.getName(); if (tag.equals("name")) { name = XMLUtilities.readString(parser, ns, "name"); } else if (tag.equals("description")) { description = XMLUtilities.readString(parser, ns, "description"); } else if (tag.equals("map")) { map = XMLUtilities.readString(parser, ns, "map"); } else { XMLUtilities.skip(parser); } } return new Venue(name, description, map); } }