Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

import org.w3c.dom.Attr;

import org.w3c.dom.Node;

public class Main {
    public static ArrayList<String> getAlternativeIDs(Node xmlSubstanceNode) {
        ArrayList<String> result = new ArrayList<String>();
        int maxID = xmlSubstanceNode.getAttributes().getLength();
        for (int i = 0; i < maxID; i++) {
            Attr oAlternative = (Attr) xmlSubstanceNode.getAttributes().getNamedItem("name" + i);
            if (oAlternative != null) {
                result.add(oAlternative.getNodeValue());
            }
        }
        return result;
    }
}