[Mono-list] Modify XML Docs

Miguel de Icaza miguel@ximian.com
05 Oct 2003 20:30:31 -0400


Hello,

> 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 = new ConfigInfo[node_username.Count];
> 
> And then start 'saving' the xml data in the struct. 
> 
> 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?

That is the beauty of the XmlSerializer: You provide it with your
structured data, and it will take care of the file format used.

If you add/remove accounts in your program, you will be making changes
to the actual data structures.  Then the serializer will write out and
read-in the structures for you.