Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static String getAttributeValue(Node node, String str) {
        if (node == null || str == null) {
            return null;
        }
        Node namedItem = node.getAttributes().getNamedItem(str);
        return namedItem != null ? namedItem.getNodeValue() : null;
    }

    public static String getNodeValue(Node node) {
        return (node == null || node.getFirstChild() == null || node.getFirstChild().getNodeValue() == null) ? null
                : node.getFirstChild().getNodeValue().trim();
    }
}