Java XML Attribute to Map toMapExcept(NamedNodeMap attrs, String... exclusions)

Here you can find the source of toMapExcept(NamedNodeMap attrs, String... exclusions)

Description

to Map Except

License

Apache License

Declaration

public static Map<String, String> toMapExcept(NamedNodeMap attrs, String... exclusions) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static Map<String, String> toMapExcept(NamedNodeMap attrs, String... exclusions) {
        Map<String, String> args = new HashMap<String, String>();
        outer: for (int j = 0; j < attrs.getLength(); j++) {
            Node attr = attrs.item(j);
            String attrName = attr.getNodeName();
            for (String ex : exclusions)
                if (ex.equals(attrName))
                    continue outer;
            String val = attr.getNodeValue();
            args.put(attrName, val);
        }/*from w w  w .j  av  a2s .  co  m*/
        return args;
    }
}

Related

  1. toMap(NamedNodeMap attrs)