Here you can find the source of getAttribute(Element ownerElem, String attrName)
Parameter | Description |
---|---|
ownerElem | the element that owns the attribute |
attrName | the name of the attribute to retrieve |
null
if that attribute does not have a specified value
public static String getAttribute(Element ownerElem, String attrName)
//package com.java2s; /*/*from w ww . jav a 2 s . c o m*/ * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as * published by JBoss Inc.; either version 1.0 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { /** * Gets an attribute value of the given element. * @param ownerElem the element that owns the attribute * @param attrName the name of the attribute to retrieve * @return the attribute value as a string, or <code>null</code> if that attribute does not have * a specified value */ public static String getAttribute(Element ownerElem, String attrName) { Attr attribute = ownerElem.getAttributeNode(attrName); return attribute != null ? attribute.getValue() : null; } }