Here you can find the source of getAllElementAttributes(Element element)
Parameter | Description |
---|---|
element | The DOM Element. |
public static String getAllElementAttributes(Element element)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; 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. com * @param element * The DOM Element. * @return A string representation of all the element's attributes. */ public static String getAllElementAttributes(Element element) { return getElementAttributes(element, new ArrayList<String>()); } /** * @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(); } }