Java XML Attribute Load getAllAttributes(Element e)

Here you can find the source of getAllAttributes(Element e)

Description

get All Attributes

License

Apache License

Declaration

public static HashMap<String, String> getAllAttributes(Element e) 

Method Source Code

//package com.java2s;
/*//from  w w w .j a  va2 s .  c om
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.HashMap;

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

public class Main {
    public static HashMap<String, String> getAllAttributes(Element e) {
        HashMap<String, String> m = new HashMap<>();
        NamedNodeMap nnm = e.getAttributes();
        for (int i = 0; i < nnm.getLength(); i++) {
            m.put(nnm.item(i).getNodeName(), nnm.item(i).getNodeValue());
        }
        return m;
    }
}

Related

  1. getAllAttributes(Element elem, String name)
  2. getAllAttributes(Element element)
  3. getAllAttributes(Node node)
  4. getAllAttributes(Node node)