Message from discussion
How do I append an Xml File?
Received: by 10.68.224.71 with SMTP id ra7mr1154545pbc.3.1346356989972;
Thu, 30 Aug 2012 13:03:09 -0700 (PDT)
X-BeenThere: android-developers@googlegroups.com
Received: by 10.68.116.38 with SMTP id jt6ls10312568pbb.8.gmail; Thu, 30 Aug
2012 13:00:38 -0700 (PDT)
Received: by 10.68.213.68 with SMTP id nq4mr1156887pbc.6.1346356838526;
Thu, 30 Aug 2012 13:00:38 -0700 (PDT)
Received: by 10.68.213.68 with SMTP id nq4mr1156886pbc.6.1346356838508;
Thu, 30 Aug 2012 13:00:38 -0700 (PDT)
Return-Path: <jackyalc...@gmail.com>
Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46])
by gmr-mx.google.com with ESMTPS id p7si413676pby.0.2012.08.30.13.00.38
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 30 Aug 2012 13:00:38 -0700 (PDT)
Received-SPF: pass (google.com: domain of jackyalc...@gmail.com designates 209.85.160.46 as permitted sender) client-ip=209.85.160.46;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jackyalc...@gmail.com designates 209.85.160.46 as permitted sender) smtp.mail=jackyalc...@gmail.com; dkim=pass header...@gmail.com
Received: by pbbrr13 with SMTP id rr13so3568925pbb.5
for <android-developers@googlegroups.com>; Thu, 30 Aug 2012 13:00:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=FpqmGeKRPil6QHOCsaEiPExLL1ZciMyhSC9syrQDaBc=;
b=aHa7EDyuy1fjfK4e7oO/IJNBR4xftTUfcAJWH06DDKHRJbkB9i7n8Ws7OL/EU3tqRg
TT2YRdMoORHg1Dh+JwThKr36D9grc6N/Tut3OdOV1yHPVZpNczuFjkMKB/BIUduEYQ3R
SYclOFGHCksLfHmlN/KThp0W799h6Tyhiue0LCdftDDUL0l3QoU+pgl1n9zsxjPcCGVS
VySPtomgCfnV7Rm89MrHCMOPMC3obhxXnBXWBa6Vm0ZJiXryIWOzgm338htuCq2IWRmA
HJarOGDzyBwLTkrNI0W27vWBXvGKqJNAIohY8jkwFtiLG6Iuf+NsTy7uU18qnsppvsme
j5ug==
Received: by 10.68.236.102 with SMTP id ut6mr13173536pbc.113.1346356838074;
Thu, 30 Aug 2012 13:00:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.213.72 with HTTP; Thu, 30 Aug 2012 12:59:57 -0700 (PDT)
In-Reply-To: <f9ff493a-9670-44d5-b8f3-501561c3b242@googlegroups.com>
References: <f9ff493a-9670-44d5-b8f3-501561c3b242@googlegroups.com>
From: =?ISO-8859-1?Q?Jacky_Alcin=E9?= <jackyalc...@gmail.com>
Date: Thu, 30 Aug 2012 15:59:57 -0400
Message-ID: <CAJYFBX1Ss6an9R0iCV+Oq1PNy3S4tFbUJp5q93jJQAkSaOV...@mail.gmail.com>
Subject: Re: [android-developers] How do I append an Xml File?
To: android-developers@googlegroups.com
Content-Type: multipart/alternative; boundary=047d7b33d98413095904c8812105
--047d7b33d98413095904c8812105
Content-Type: text/plain; charset=ISO-8859-1
Why not use a DOM parser?
On Thu, Aug 30, 2012 at 3:42 PM, Guilherme Bernardi <
gui.bernard...@gmail.com> wrote:
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
Jacky Alcine
Blog <http://blog.jalcine.me> | Launchpad<https://launchpad.net/~jackyalcine>
--047d7b33d98413095904c8812105
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<font>Why not use a DOM parser?<br></font><br><div class=3D"gmail_quote">On=
Thu, Aug 30, 2012 at 3:42 PM, Guilherme Bernardi <span dir=3D"ltr"><<a =
href=3D"mailto:gui.bernard...@gmail.com" target=3D"_blank">gui.bernardi09@g=
mail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Hi.<div><br></div><div>I'm trying to app=
end an Xml Data File.</div><div><br></div><div>The structure of Xml is:</di=
v>
<div><br></div><div><?xml version=3D'1.0' encoding=3D'UTF-8&=
#39; standalone=3D'yes' ?><br></div><div><clientes></div><=
blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div><div>&l=
t;cliente4></div>
</div></blockquote><blockquote style=3D"margin:0 0 0 40px;border:none;paddi=
ng:0px"><div><div>=A0 =A0 <Empresa>1</Empresa></div></div></blo=
ckquote><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><di=
v><div>
=A0 =A0 <Codigo>5</Codigo></div></div></blockquote><blockquote =
style=3D"margin:0 0 0 40px;border:none;padding:0px"><div><div>=A0 =A0 <N=
ome>gsdf</Nome></div></div></blockquote><blockquote style=3D"margi=
n:0 0 0 40px;border:none;padding:0px">
<div><div>=A0 =A0 <Endereco>ags</Endereco></div></div></blockqu=
ote><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div><d=
iv>=A0 =A0 <Bairro>gasd</Bairro></div></div></blockquote><block=
quote style=3D"margin:0 0 0 40px;border:none;padding:0px">
<div><div></cliente4></div></div></blockquote><div></clientes><=
/div><div><br></div><div>I need to add another record. I got it, but the ne=
w record was inserted like this:</div><div><br></div><div><div><?xml ver=
sion=3D'1.0' encoding=3D'UTF-8' standalone=3D'yes' =
?><br>
</div><div><clientes></div><blockquote style=3D"margin:0px 0px 0px 40=
px;border:none;padding:0px"><cliente4></blockquote><blockquote style=
=3D"margin:0px 0px 0px 40px;border:none;padding:0px">=A0 =A0 <Empresa>=
;1</Empresa></blockquote>
<blockquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0px">=A0 =
=A0 <Codigo>5</Codigo></blockquote><blockquote style=3D"margin:=
0px 0px 0px 40px;border:none;padding:0px">=A0 =A0 <Nome>gsdf</Nome=
></blockquote>
<blockquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0px">=A0 =
=A0 <Endereco>ags</Endereco></blockquote><blockquote style=3D"m=
argin:0px 0px 0px 40px;border:none;padding:0px">=A0 =A0 <Bairro>gasd&=
lt;/Bairro></blockquote>
<blockquote style=3D"margin:0px 0px 0px 40px;border:none;padding:0px"></=
cliente4></blockquote><div></clientes><b><cliente6><TESTE=
>testando</TESTE></cliente6><cliente6><TESTE>tes=
tando</TESTE></cliente6><cliente6><TESTE>testando&l=
t;/TESTE></cliente6></b></div>
</div><div><b><br></b></div><div>How can I get the position of </cliente=
4> and append the new record or can I delete the EndTag </clientes>=
; and add the new record and set the EndTag again?</div><div><br></div>
<div>To appending the file I'm using:</div><div><br></div><blockquote s=
tyle=3D"margin:0 0 0 40px;border:none;padding:0px"><div><div>OutputStream i=
s =3D openFileOutput("cliente.xml", MODE_APPEND);</div></div></bl=
ockquote>
<div><div>=A0 =A0 =A0 =A0 =A0 =A0 XmlSerializer serializer =3D Xml.newSeria=
lizer();</div><div>=A0 =A0 =A0 =A0 =A0 =A0 serializer.setOutput(is, "U=
TF-8");</div><div>=A0 =A0 =A0 =A0 =A0 =A0 serializer.startTag(null, &q=
uot;cliente6");</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<span style=
=3D"white-space:pre-wrap"> </span>serializer.startTag(null, "TESTE&quo=
t;);</div>
<div><span style=3D"white-space:pre-wrap"> </span> =A0 =A0<span style=3D"wh=
ite-space:pre-wrap"> </span>serializer.text("testando");</div><di=
v><span style=3D"white-space:pre-wrap"> </span> =A0 =A0<span style=3D"white=
-space:pre-wrap"> </span>serializer.endTag(null, "TESTE");</div>
<div>=A0 =A0 =A0 =A0 =A0 =A0 serializer.endTag(null,"cliente6");<=
/div><div>=A0 =A0 =A0 =A0 =A0 =A0 serializer.endDocument();</div><div>=A0 =
=A0 =A0 =A0 =A0 =A0 serializer.flush();</div><div>=A0 =A0 =A0 =A0 =A0 =A0 i=
s.close();</div></div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google<br>
Groups "Android Developers" group.<br>
To post to this group, send email to <a href=3D"mailto:android-developers@g=
ooglegroups.com" target=3D"_blank">android-developers@googlegroups.com</a><=
br>
To unsubscribe from this group, send email to<br>
<a href=3D"mailto:android-developers%2Bunsubscribe@googlegroups.com" target=
=3D"_blank">android-developers+unsubscribe@googlegroups.com</a><br>
For more options, visit this group at<br>
<a href=3D"http://groups.google.com/group/android-developers?hl=3Den" targe=
t=3D"_blank">http://groups.google.com/group/android-developers?hl=3Den</a><=
/font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br=
>Jacky Alcine<div>
<a href=3D"http://blog.jalcine.me" target=3D"_blank">Blog</a>=A0|=A0<a href=
=3D"https://launchpad.net/~jackyalcine" target=3D"_blank">Launchpad</a></di=
v><br>
--047d7b33d98413095904c8812105--