XmlDocument.java
3.4 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.airport.util.parse;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class XmlDocument {
private Document document = null;
private SAXBuilder builder = null;
private Element root = null;
private String xmlFile;
public XmlDocument(String xmlFileName) {
this.xmlFile = xmlFileName;
try {
this.builder = new SAXBuilder();
this.document = new Document();
this.document = this.builder.build(this.xmlFile);
} catch (JDOMException var3) {
var3.printStackTrace();
} catch (IOException var4) {
var4.printStackTrace();
}
}
public void destory() {
this.document = null;
this.root = null;
this.builder = null;
}
public String getStringFromInnerText(String xmlNodePath) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getText();
n = null;
} catch (Exception var12) {
var12.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
public String getStringFromXmlNodeAttribute(String xmlNodePath, String attributeName, String defaultValue) {
String[] nodes = xmlNodePath.split("/");
LinkedList<SubNode> listNode = new LinkedList();
String value = "";
try {
for(int i = 1; i < nodes.length; ++i) {
SubNode snode;
if (i > 1) {
snode = (SubNode)listNode.getLast();
List<Element> eList = snode.getElement().getChildren(nodes[i]);
if (eList != null && eList.size() > 0) {
SubNode s1 = new SubNode((Element)eList.get(0));
listNode.add(s1);
}
} else if (1 == i) {
this.root = this.document.getRootElement();
snode = new SubNode(this.root);
listNode.add(snode);
}
}
SubNode n = (SubNode)listNode.getLast();
value = n.getElement().getAttributeValue(attributeName, defaultValue);
n = null;
} catch (Exception var14) {
var14.printStackTrace();
} finally {
listNode.clear();
}
return value;
}
}