我试图修改使用JDOM和变压器的概念XML数据,这两个功能在2.2版本的作品。但每当我试图编译2.1我收到异常。此外,我在谷歌搜索到这个问题,他们提到2.1版不会支持变压器的概念。什么是修改的XML文件的另一种方法。
I tried to modify XML data using JDOm and transformer concept, this two functions are works in 2.2 version. but whenever i tried to compile in 2.1 i am getting exception. Also i searched this issue in google, they mentioned 2.1 version never support transformer concept. what is the alternative way to modify XML file.
String filePath = Environment.getExternalStorageDirectory() + getDir;
File file = new File(filePath);
if (file.exists()) {
Document document = (Document) builder.build(file);
Element root = document.getRootElement();
Element EditableTag = root.getChild("firsttag");
EditableTag.setText("changed String");
/**
* Print the modified xml document
*/
String des = new XMLOutputter().outputString(document);
System.out.println("String: " + des);
/**
* Modify the orginal document using FileWritter
*/
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(des);
fileWriter.close();
}
这code是在2.2版本的作品,同时我编这2.1我收到FleNotFound例外。
This code is works in 2.2 version, at the same time i compile this in 2.1 i am getting FleNotFound exception.
您可以使用简单的XML 读取XML文件中的对象,修改它的状态和写回。
You can use Simple XML to read the xml-file in the object, modify its state and write it back.
上一篇:如何运行对一个发布版本的Android APK / Robotium仪器测试案例?案例、版本、仪器、测试
下一篇:Android的 - java.lang.IllegalArgumentException异常Erron在2.1和低的Android创建对话框时,对话框、异常、lang、IllegalArgum