日期:2014-05-20 浏览次数:20983 次
public ArrayList readerXML() {
ArrayList <String> multiWindowSettingList = new ArrayList <String> ();
SAXBuilder builder = new SAXBuilder(false);
try {
java.io.File file=new java.io.File(xmlPath)
Document doc = builder.build(file);
Element root = doc.getRootElement();
Element AutoSetName = root.getChild("AutoSetName");
Element AutoRefresh = root.getChild("isAutoRefesh");
String autoSetName = AutoSetName.getAttributeValue("isAutoSetName");
String autoSetNameVal = AutoSetName.getAttributeValue("val");
String autoRefresh = AutoRefresh.getAttributeValue("isAutoRefesh");
String autoRefreshVal = AutoRefresh.getAttributeValue("val");
multiWindowSettingList.add(autoSetName);
multiWindowSettingList.add(autoSetNameVal);
multiWindowSettingList.add(autoRefresh);
multiWindowSettingList.add(autoRefreshVal);
XMLOutputter outputter = new XMLOutputter();
FileOutputStream f = new FileOutputStream(xmlPath);
outputter.output(doc, f);
f.close();
} catch (FileNotFoundException e) {
createXML();
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return multiWindowSettingList;
}
------解决方案--------------------
这里有路径的处理方法,不知道对你有没有用处。但值得学习