I'm trying to save data to the sdcard.
Currently I have a working
if ( xmlFile.createNewFile() ) {
//Creating a new XML File Thus count = 1 we are the first entry
Appending = false;
Write = new FileWriter(xmlFile, false);
count = 1;
serializer.setOutput(Write);
serializer.startDocument("UTF-8", false);
serializer.startTag(null, "ROOT");
} else {
// Appending to XML File
Appending = true;
Write = new FileWriter(xmlFile, true);
try {
// Determine the current Number of records
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
Document Doc =
factory.newDocumentBuilder().parse(xmlFile);
NodeList nodes = Doc.getElementsByTagName("Client");
count = nodes.getLength() + 1;
} catch(Exception e) {
throw new RuntimeException(e);
}
serializer.setOutput(Write);
}
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output",
true);
...
... Write the XML File
This produces after two runs
<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
<ROOT>
<Client>
<Name>qwerty</Name>
<Code>qwe-0001</Code>
</Client>
</ROOT><Client><Name>gghhjj</Name><Code>ggh-0002</Code></Client>
I expected
<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
<ROOT>
<Client>
<Name>qwerty</Name>
<Code>qwe-0001</Code>
</Client>
<Client>
<Name>gghhjj</Name>
<Code>ggh-0002</Code>
</Client>
</ROOT>
How do I correct this ? Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en