Code example for Element

Methods: getAttribute, hasAttribute

0
		if (testNode.getNodeType() == Node.ELEMENT_NODE) {
			// Node to test is element 
			Element element = (Element) testNode;
			if (indexWildcard != -1) {
				// wildcard is defined in the attribute matcher. 
				if (element.hasAttribute(attrName)) {
					// element define, attribute, match is OK. 
					if (wildcardValues != null) {
						// wildcard values is filled, add the attribute value 
						wildcardValues.add(element.getAttribute(attrName));
					} 
					// element tested define the attribute, match is OK 
					return true; 
				} 
				return false; 
			} 
			// No wildcard defined, test if element has attribute attrName and 
			// if value is OK. 
			String testAttrValue = element.getAttribute(attrName);
			return attrValue.equals(testAttrValue);
		} 
		return false; 
	}