Java XML Attribute Get getAttributeIgnoreCase(Element element, String string)

Here you can find the source of getAttributeIgnoreCase(Element element, String string)

Description

get Attribute Ignore Case

License

Open Source License

Parameter

Parameter Description
element a parameter
string a parameter

Return

the attribute named string on element ignoring case in the comparison or null if not found

Declaration

public static String getAttributeIgnoreCase(Element element, String string) 

Method Source Code

//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   w  w  w. j ava 2 s  .  c  o  m
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/

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

public class Main {
    /**
     * @param element
     * @param string
     * @return the attribute named string on element ignoring case in the comparison
     * or null if not found
     */
    public static String getAttributeIgnoreCase(Element element, String string) {
        NamedNodeMap map = element.getAttributes();
        for (int i = 0; i < map.getLength(); i++) {
            Node attr = map.item(i);
            if (string.equalsIgnoreCase(attr.getNodeName())) {
                return attr.getNodeValue();
            }
        }
        return null;
    }
}

Related

  1. getAttributeEnum(Node node, String attributeName, Class enumClass)
  2. getAttributeFloatValue(String attribute, NamedNodeMap namedNodeMap)
  3. getAttributeFromClosestAncestorOfAnyKind(Node node, String attributeName)
  4. getAttributeIfExists(Node node, String name)
  5. getAttributeIgnoreCase(Element element, String attributeName)
  6. getAttributeIntArray(final Node node, final String attribname)
  7. getAttributeInteger(String filename, Element parent, String name)
  8. getAttributeInteger(String filename, Element parent, String name)
  9. getAttributeIntValue(Node n, String item, int dflt)