Java XML Attribute Get getAttributeByLocalName(XMLStreamReader reader, String localName)

Here you can find the source of getAttributeByLocalName(XMLStreamReader reader, String localName)

Description

get Attribute By Local Name

License

Apache License

Declaration

public static String getAttributeByLocalName(XMLStreamReader reader, String localName) 

Method Source Code


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

import javax.xml.namespace.QName;

import javax.xml.stream.XMLStreamReader;

public class Main {
    public static String getAttributeByLocalName(XMLStreamReader reader, String localName) {
        String result = "";
        for (int i = 0; i < reader.getAttributeCount(); i++) {
            QName attribute = reader.getAttributeName(i);
            if (attribute != null && attribute.getLocalPart().equals(localName)) {
                result = reader.getAttributeValue(i);
            }/*from w ww  .  j ava2  s  . com*/
        }
        return result;
    }
}

Related

  1. getAttributeBoolean(Node node, String attributeName)
  2. getAttributeBoolean(Node node, String name)
  3. getAttributeBooleanByName(NamedNodeMap nnm, String name)
  4. getAttributeBooleanByName(NamedNodeMap nnm, String name)
  5. getAttributeByIndex(final Element element, final int index)
  6. getAttributeByName(final List elements, final String attributeName)
  7. getAttributeByName(Node content, String attributeName)
  8. getAttributeByName(Node node, String name, boolean defaultValue)
  9. getAttributeByName(Node node, String name, String defaultValue)