Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected List readOne(XmlPullParser parser) throws ParserConfigurationException, SAXException, XmlPullParserException, XPathExpressionException, IOException, NetworkOnMainThreadException {
- List entries = new ArrayList();
- parser.require(XmlPullParser.START_TAG, ns, "profile");
- while (parser.next() != XmlPullParser.END_TAG) {
- if (parser.getEventType() != XmlPullParser.START_TAG) {
- continue;
- }
- String name = parser.getName();
- // Starts by looking for the player tag
- if (name.equals("player")) {
- entries.add(readOnePlayer(parser));
- } else {
- skip(parser);
- }
- }
- return entries;
- }
- parser.require(XmlPullParser.START_TAG, ns, "player");
- int id = Integer.parseInt(parser.getAttributeValue(ns, "id"));
- String name = parser.getAttributeValue(null, "name");
- int totalKills = Integer.parseInt(parser.getAttributeValue(null, "totalKills"));
- int score = 0;
- while (parser.next() != XmlPullParser.END_TAG) {
- if (parser.getEventType() != XmlPullParser.START_TAG) {
- continue;
- }
- String tagName = parser.getName();
- if (id == ProfileSummary.thisID + 1) {
- if (tagName.equals("score")) {
- score = Integer.parseInt(readName(parser, "score"));
- } else {
- skip(parser);
- }
- } else {
- skip(parser);
- }
- }
- return new Player(id, name, totalKills, score);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement