Hi all, I want to create an XML file to Store my Application Settings into. ( I can't use SharedPrefs because i want that Settings file later to be accessed by Some other Code.)
I can easily create an XML with java's code and store it in File too. but in Android I can create xml with the same java code but can't save it into the file coz they have removed the package javax.xml.transform from SDK. Can anyone please help me out... I am Attaching the Java code here... public class CreatXMLFile { public static void main(String[] args) throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.newDocument(); Element rootElement = document.createElement("map"); document.appendChild(rootElement); Element em = document.createElement("string"); em.setAttribute("name", "FirstName"); em.appendChild(document.createTextNode("Rita")); rootElement.appendChild(em); em = document.createElement("string"); em.setAttribute("name", "LastName"); em.appendChild(document.createTextNode("Roy")); rootElement.appendChild(em); TransformerFactory transformerFactory = TransformerFactory.newInstance (); // This code Transformer transformer = transformerFactory.newTransformer(); // doesn't work DOMSource source = new DOMSource(document); // with Android StreamResult result = new StreamResult("c:\ \abc.xml"); // :( transformer.transform(source, result); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---