Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

import org.w3c.dom.*;

public class Main {
    /**
     * Returns all attributes of the given XML node as a list of name=value strings.
     * Mostly just for debugging.
     * @param node
     * @return
     */
    public static List<String> getAttributes(Node node) {
        List<String> result = new ArrayList<String>();
        NamedNodeMap attrs = node.getAttributes();
        for (int i = 0; i < attrs.getLength(); i++) {
            Node attrNode = attrs.item(i);
            result.add(attrNode.getNodeName() + "=" + attrNode.getNodeValue());
        }
        return result;
    }
}