Android: DOM Model for XML
analogue of this ( Replacing XML in a file from "Document" in Java or http://www.exampledepot.com/egs/javax.xml.transform/WriteDom.html ) I am trying to use it under Android ...
The problem is I can't use the suggested solution under android because it is throwing java.lang.verifyError ...
After reading a bit, I found out that the class that was used to store data in a file is not used in android ...
can you suggest another solution that is similarly easy to use?
a source to share
This link should also show a good example from IBM how to use DOM for XML on Android
http://www.ibm.com/developerworks/opensource/library/x-android/index.html#N1025A
a source to share
This code should work directly on Android, but unfortunately from API Level 8 which includes the Java XML Transformer API .
Unfortunately, this Android version is fairly new (days) and the official phone firmware based on this platform version is not yet available for any current terminal (but the Nexus One), although at least some manufacturers have said they will support it on the recently released models: HCT , Motorola .
a source to share
You can use XMLSerializer
.
Example:
FileOutputStream fos = mContext.openFileOutput("filename", Context.MODE_PRIVATE);
BufferedOutputStream buf = new BufferedOutputStream(fos);
XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
serializer.setOutput(buf, "utf-8");
serializer.startDocument("utf-8", Boolean.TRUE);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "yourRootTag");
... etc. Android API docs here .
a source to share