-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainClass.java
More file actions
47 lines (38 loc) · 1.48 KB
/
Copy pathMainClass.java
File metadata and controls
47 lines (38 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class MainClass
{
public static void main(String[] args) throws Exception
{
File fXmlFile = new File("D:\\MyDropbox\\Dropbox\\My Java Workspace\\TradeInsert\\config\\app.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
Element root = doc.getDocumentElement();
System.out.print(root.getElementsByTagName("LoadCustomLookAndFeel").item(0).getTextContent());
NodeList nodeList = root.getElementsByTagName("*");
for(int i=0;i<nodeList.getLength();i++)
{
System.out.println(nodeList.item(i).getNodeName() + " -> " + nodeList.item(i).getTextContent());
System.out.println(nodeList.item(i).hasAttributes());
}
NodeList nList = doc.getElementsByTagName("dbConnection");
Node node = nList.item(0);
System.out.println("\nCurrent Element :" + node.getNodeName());
if (node.getNodeType() == Node.ELEMENT_NODE)
{
Element eElement = (Element)node;
System.out.println("First Name : " + eElement.getElementsByTagName("databaseDriverClassName").item(0).getTextContent());
}
}
private void fetchConfigurationFromXMLFile()
{
}
}