Here you can find the source of getElementAttributes(Element element, List
Parameter | Description |
---|---|
element | The DOM Element. |
exclude | the list of exclude strings. |
public static String getElementAttributes(Element element, List<String> exclude)
//package com.java2s; //License from project: Apache License import java.util.List; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; public class Main { /**//from w w w . j a v a 2 s .c o m * @param element * The DOM Element. * @param exclude * the list of exclude strings. * @return A string representation of the element's attributes excluding exclude. */ public static String getElementAttributes(Element element, List<String> exclude) { StringBuffer buffer = new StringBuffer(); if (element != null) { NamedNodeMap attributes = element.getAttributes(); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { Attr attr = (Attr) attributes.item(i); if (!exclude.contains(attr.getNodeName())) { buffer.append(attr.getNodeName() + "="); buffer.append(attr.getNodeValue() + " "); } } } } return buffer.toString().trim(); } }