[Mono-list] Modify XML Docs

2003-10-05 Thread Pablo Fischer
Hi!

Im creating an app (mBloggy, to post 'posts' to a blog), however I'm
going to use a xml file to save the user configuration (the blogs).
Today I can write (JUST new files), read it and identify some parts, but
I dont undestand what the inet says about modifying xml files, so How
can I modify an xml file? to modify nodes and remove elements, for
example:


 
  Pablo
  Crypted
  Personal WebSite
  http://pablo.com.mx/xmlrpc.php
 
   
... the same..
  


Thanks!
-- 
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

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Martin Willemoes Hansen




On Sun, 2003-10-05 at 20:04, Pablo Fischer wrote:

Hi!

Im creating an app (mBloggy, to post 'posts' to a blog), however I'm
going to use a xml file to save the user configuration (the blogs).
Today I can write (JUST new files), read it and identify some parts, but
I dont undestand what the inet says about modifying xml files, so How
can I modify an xml file? to modify nodes and remove elements, for
example:


 
  Pablo
  Crypted
  Personal WebSite
  http://pablo.com.mx/xmlrpc.php
 
 	
	... the same..
  



Will it be free software I can download some day? .. Im looking for some good bloging software you see.

Happy hacking


Thanks!




-- 
Martin Willemoes Hansen


E-Mail	[EMAIL PROTECTED]	Website	mwh.sysrq.dk
IRC MWH, freenode.net
   









Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Pablo Fischer
El dom, 05-10-2003 a las 13:28, Martin Willemoes Hansen escribió:
> Will it be free software I can download some day? .. Im looking for
> some good bloging software you see.
Of course it will be free!, I think im in the 80% of the app, Im just in
the 'user configuration' part and the 'format text' (bold, italics,
underline, bla bla).

But today I can 'talk' with the xmlrpc file in my server and post
messages.

> 
> Happy hacking
> 
> > Thanks!
> 
> -- 
> Martin Willemoes Hansen
> 
> 
> E-Mail[EMAIL PROTECTED]   Website mwh.sysrq.dk
> IRC MWH, freenode.net
>    
-- 
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


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Miguel de Icaza
Hello,

> Im creating an app (mBloggy, to post 'posts' to a blog), however I'm
> going to use a xml file to save the user configuration (the blogs).
> Today I can write (JUST new files), read it and identify some parts, but
> I dont undestand what the inet says about modifying xml files, so How
> can I modify an xml file? to modify nodes and remove elements, for
> example:
> 
> 
>  
>   Pablo
>   Crypted
>   Personal WebSite
>   http://pablo.com.mx/xmlrpc.php
>  
>  
>   ... the same..
>   
> 

This sounds like a prime candidate for XmlSerialization, use:

public class mbloggy {
public Account [] accounts;
}

public class account {
public string username;
public string password;
public string identifier;
public string url;
}

mbloggy m = new mbloggy ();
account a = new Account;
m.accounts = new Account [1];
m.accounts [0] = a;
a.username = "Miguel";
a.identifier = "...";

XmlSerializer s = new XmlSerializer (typeof (mbloggy));
s.Serialize (Console.Out, m);

Miguel
___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Pablo Fischer
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 = 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?

Thanks!

El dom, 05-10-2003 a las 13:38, Miguel de Icaza escribió:
> Hello,
> This sounds like a prime candidate for XmlSerialization, use:
> 
> public class mbloggy {
>   public Account [] accounts;
> }
> 
> public class account {
>   public string username;
>   public string password;
>   public string identifier;
>   public string url;
> }
> 
> mbloggy m = new mbloggy ();
> account a = new Account;
> m.accounts = new Account [1];
> m.accounts [0] = a;
> a.username = "Miguel";
> a.identifier = "...";
> 
> XmlSerializer s = new XmlSerializer (typeof (mbloggy));
> s.Serialize (Console.Out, m);
> 
> Miguel
-- 
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

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Ben Maurer
On Sun, 2003-10-05 at 14:52, Pablo Fischer wrote:
> 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 = 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
You can use an array list so you can add/remove accounts (see the msdn
docs)
>  or
> modify something (like the password)
you can modify the information
> , how can I save that to my xml
> file?
Reserialize it. Read the msdn docs.

As well, both monologue and monodoc have some examples of Xml
Serialization, you may want to check them out.

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Pablo Fischer
Hi!

Ok, I'll check the xml serialization, however the configuration NEEDS to
be saved in a file, not in 'the fly', so every change to the accounts
needs to be saved to the file (and then to the array, an array list or a
struct array).

Thanks!
El dom, 05-10-2003 a las 14:44, Ben Maurer escribió:
> You can use an array list so you can add/remove accounts (see the msdn
> docs)
> >  or
> > modify something (like the password)
> you can modify the information
> > , how can I save that to my xml
> > file?
> Reserialize it. Read the msdn docs.
> 
> As well, both monologue and monodoc have some examples of Xml
> Serialization, you may want to check them out.
> 
> ___
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
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

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Miguel de Icaza
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.
___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs

2003-10-05 Thread Pablo Fischer
Hi!

Yeah, I didnt know that, now I'm using two classes, arraylist (in one
class) and the XmlSerializer and I can add, remove and modify accounts.
And everytime the user want's to exit from mBloggy the XmlSerializer
will update the XmlFile.

Thanks!
El dom, 05-10-2003 a las 19:30, Miguel de Icaza escribió:
> 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.
> ___
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
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

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Modify XML Docs (part 2)

2003-10-05 Thread Pablo Fischer
Uhm.. 

After sending the last reply I think in that option.. 

1. Load the xml file like you and Miguel says
2. Work in the array list with add/remove
3. After closing the app (delete_event), creates the new xml file

Is it a good idea?

Thanks!
El dom, 05-10-2003 a las 14:44, Ben Maurer escribió:
> On Sun, 2003-10-05 at 14:52, Pablo Fischer wrote:
> > 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 = 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
> You can use an array list so you can add/remove accounts (see the msdn
> docs)
> >  or
> > modify something (like the password)
> you can modify the information
> > , how can I save that to my xml
> > file?
> Reserialize it. Read the msdn docs.
> 
> As well, both monologue and monodoc have some examples of Xml
> Serialization, you may want to check them out.
> 
> ___
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
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

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list