Note that this is a very inefficient way to do this. XML really doesn't lend itself to append operations. If you have some stored data that you are going to be appending to, I would seriously consider some format besides XML.
On Thu, Aug 30, 2012 at 1:39 PM, Guilherme Bernardi < [email protected]> wrote: > Ok, I'll start... and post the results. > > Thank you. > > Em quinta-feira, 30 de agosto de 2012 16h42min36s UTC-3, Guilherme > Bernardi escreveu: > >> Hi. >> >> I'm trying to append an Xml Data File. >> >> The structure of Xml is: >> >> <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> >> <clientes> >> >> <cliente4> >> >> <Empresa>1</Empresa> >> >> <Codigo>5</Codigo> >> >> <Nome>gsdf</Nome> >> >> <Endereco>ags</Endereco> >> >> <Bairro>gasd</Bairro> >> >> </cliente4> >> >> </clientes> >> >> I need to add another record. I got it, but the new record was inserted >> like this: >> >> <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> >> <clientes> >> >> <cliente4> >> >> <Empresa>1</Empresa> >> >> <Codigo>5</Codigo> >> >> <Nome>gsdf</Nome> >> >> <Endereco>ags</Endereco> >> >> <Bairro>gasd</Bairro> >> >> </cliente4> >> >> </clientes>*<cliente6><TESTE>testando</TESTE></cliente6>< >> cliente6><TESTE>testando</TESTE></cliente6><cliente6>< >> TESTE>testando</TESTE></cliente6>* >> * >> * >> How can I get the position of </cliente4> and append the new record or >> can I delete the EndTag </clientes> and add the new record and set the >> EndTag again? >> >> To appending the file I'm using: >> >> OutputStream is = openFileOutput("cliente.xml", MODE_APPEND); >> >> XmlSerializer serializer = Xml.newSerializer(); >> serializer.setOutput(is, "UTF-8"); >> serializer.startTag(null, "cliente6"); >> serializer.startTag(null, "TESTE"); >> serializer.text("testando"); >> serializer.endTag(null, "TESTE"); >> serializer.endTag(null,"**cliente6"); >> serializer.endDocument(); >> serializer.flush(); >> is.close(); >> > -- > 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 > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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

