[Mono-list] Modify XML Docs

Pablo Fischer pablo@pablo.com.mx
Sun, 05 Oct 2003 13:52:30 -0500


Hello Miguel!

Well Im creating something like that, cause I'm loading the xmlfile
(LoadConfigFile) in a struct like this:

  private struct ConfigInfo {
	string username;
	string password;
	string url;
	string identifier;
  }

So if the file exists I 'load' the file in a struct

ConfigInfo[] configtmp =3D new ConfigInfo[node_username.Count];

And then start 'saving' the xml data in the struct.=20

Once I have the configtmp loaded I just use it every time I need some
information. But what happens if the user wants to remove an account or
modify something (like the password), how can I save that to my xml
file?

Thanks!

El dom, 05-10-2003 a las 13:38, Miguel de Icaza escribi=F3:
> Hello,
> This sounds like a prime candidate for XmlSerialization, use:
>=20
> public class mbloggy {
> 	public Account [] accounts;
> }
>=20
> public class account {
> 	public string username;
> 	public string password;
> 	public string identifier;
> 	public string url;
> }
>=20
> mbloggy m =3D new mbloggy ();
> account a =3D new Account;
> m.accounts =3D new Account [1];
> m.accounts [0] =3D a;
> a.username =3D "Miguel";
> a.identifier =3D "...";
>=20
> XmlSerializer s =3D new XmlSerializer (typeof (mbloggy));
> s.Serialize (Console.Out, m);
>=20
> Miguel
--=20
Pablo Fischer Sandoval (pablo [arroba/at] pablo.com.mx)
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt