1 package eu.svjatoslav.inspector.xml.xsd;
3 import java.util.ArrayList;
6 import org.w3c.dom.Element;
7 import org.w3c.dom.NamedNodeMap;
8 import org.w3c.dom.Node;
10 public class XmlElement {
14 public XmlElement(final Element element) {
15 this.element = element;
18 public List<String> getAttributeNames() {
19 final ArrayList<String> result = new ArrayList<String>();
21 final NamedNodeMap attributes = element.getAttributes();
23 for (int i = 0; i < attributes.getLength(); i++) {
24 final Node node = attributes.item(i);
26 result.add(node.getNodeName());
32 public String getAttributeValue(final String attributeName) {
33 return element.getAttribute(attributeName);
37 public String toString() {
38 final StringBuffer result = new StringBuffer();
40 result.append("node name: " + element.getNodeName() + "\n");
42 final NamedNodeMap attributes = element.getAttributes();
44 for (int i = 0; i < attributes.getLength(); i++) {
45 final Node node = attributes.item(i);
47 result.append(" " + node.getNodeName() + "\n");
50 return result.toString();