Here you can find the source of getAttributeMap(NamedNodeMap nodeMap)
Parameter | Description |
---|---|
nodeMap | NamedNodeMap type |
public static Map getAttributeMap(NamedNodeMap nodeMap)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 Sybase, Inc. and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from ww w. ja v a 2 s . c o m*/ * Sybase, Inc. - initial API and implementation *******************************************************************************/ import java.util.HashMap; import java.util.Map; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** * Change NamedNodeMap type to Map type * * @param nodeMap * NamedNodeMap type * @return the map */ public static Map getAttributeMap(NamedNodeMap nodeMap) { if (nodeMap != null) { int len = nodeMap.getLength(); HashMap map = new HashMap(); for (int i = 0; i < len; i++) { Node node = nodeMap.item(i); String name = node.getNodeName(); String value = node.getNodeValue(); if (name != null && !name.trim().equalsIgnoreCase("") && value != null) //$NON-NLS-1$ { map.put(name, value); } } return map; } return null; } }