Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.*;

public class Main {
    public static String getBrandName() {
        try {
            DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = dFactory.newDocumentBuilder();
            Document doc = builder.parse(new File("configTV.xml"));

            NodeList nl = doc.getElementsByTagName("Name");
            Node classNode = nl.item(0).getFirstChild();
            String Name = classNode.getNodeValue().trim();
            return Name;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}