Java XML Attribute Set attributeMap(Element element)

Here you can find the source of attributeMap(Element element)

Description

attribute Map

License

Open Source License

Declaration

public static Map<String, String> attributeMap(Element element) 

Method Source Code

//package com.java2s;
/* //from w w  w  .j a v  a2  s .c  o m
* This file is part of DISMOD Core. 
* ? Copyright 2003-2011 Fraunhofer Institut f. Materialfluss und Logistik.
* http://www.iml.fraunhofer.de, http://www.verkehrslogistik.de
*
* DISMOD Core is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* DISMOD Core is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public License
* along with DISMOD Core.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.util.HashMap;

import java.util.Map;

import org.w3c.dom.Attr;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

public class Main {
    public static Map<String, String> attributeMap(Element element) {
        NamedNodeMap n = element.getAttributes();

        HashMap<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < n.getLength(); i++) {
            Attr a = (Attr) n.item(i);
            map.put(a.getName(), a.getValue());
        }

        return map;
    }
}

Related

  1. attributeBooleanGet(Element e, String name, boolean defaultValue)
  2. attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue)
  3. attributeBoolValue(Element e, String attr)
  4. attributeFloat(Node node, String attributeName)
  5. attributeIntValue(Element e, String attr)
  6. attributeOrNull(Node node, String... attributes)
  7. attributeOrValue(Element element, String mainAttribute, String... alternateAttributes)
  8. attributes(final Element element)
  9. attributesAsMap(Element element)