Java tutorial
//package com.java2s; /* * Java * * Copyright 2014 IS2T. All rights reserved. * Use of this source code is governed by a BSD-style license that can be found at http://www.is2t.com/open-source-bsd-license/. */ import java.util.HashMap; import org.xmlpull.v1.XmlPullParser; public class Main { /** * Parses the attributes of a node. * * @param parser * the parser. * @return a hashtable containing the attributes. */ public static HashMap<String, String> parseAttributes(XmlPullParser parser) { int attributeCount = parser.getAttributeCount(); HashMap<String, String> attributes = new HashMap<>(attributeCount); for (int i = -1; ++i < attributeCount;) { attributes.put(parser.getAttributeName(i), parser.getAttributeValue(i)); } return attributes; } }