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();
}
This code is works in 2.2 version, at the same time i compile this in 2.1 i am getting FleNotFound exception.