[Mono-list] Xml reading & writing.

Petit Eric surfzoid at gmail.com
Wed Sep 17 04:13:25 EDT 2008


2008/9/17 Jonathan Pryor <jonpryor at vt.edu>:
> On Wed, 2008-09-17 at 02:43 +0100, Neil Munro wrote:
>> I have an xml file that is my applications preferences, it's an update
>> tool, now this update tool can update from multiple sources. If no
>> preferences file is found on first run, a default set are saved. Now
>> if the user wishes to add a new update source to the xml file I need
>> to place the <UpdateSource>blah</UpdateSource> in the correct part of
>> the file, since the file holds ALL application preferences, I can't
>> just dump a new source at the end of the text file.
>>
>> I guess my question is, what's the best way to solve this problem?
>
> As with many things, there are *several* ways to do this:
>
>  * System.Xml.XmlDocument:
>    http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx
>    Provides a DOM oriented XML manipulation API.
>    Pro: Somewhat easy to use.
>    Con: Loads the entire document into memory, so not very useful for
>         large documents.
>
>  * System.Xml.XmlReader & System.Xml.XmlWriter:
>    http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx
>    http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx
>    Pro: Provides a "pull-model" API so that the entire document need
>         not be loaded at once.
>    Con: Not as easy to use as XmlDocument.
>
>  * System.Xml.XPath.IXPathNavigable
>    http://msdn.microsoft.com/en-us/library/system.xml.xpath.ixpathnavigable.aspx
>    Allows reading/writing of XML-like data w/o requiring XML, but
>    needs an actual implementation that supports reading/writing,
>    which XmlNode (and thus XmlDocument) do.
>
> And I'm probably missing a few...
>
> Unless you're working with a large document (read: several MB and
> larger), I'd suggest either XmlDocument or IXPathNavigable for starters.
>
>  - Jon
Ms provide a "build in" class to use app xml files
    using System.Configuration;

    string aExcelFile;
    aExcelFile = ConfigurationSettings.AppSettings.Get("MyExcelFileName");

But i find it not enought "flexible" so i use my custom one :
http://monoosc.svn.sourceforge.net/viewvc/monoosc/MonoOSC/MonoOSC/Class/ConfigReaderWriter.cs?revision=30&view=markup
>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>



-- 

Cordially.

Small Eric Quotations of the days:
---------------------------------------------------------------------------
If one day one reproaches you that your work is not a work of
professional, say you that:
Amateurs built the arch of Noah, and professionals the Titanic.
---------------------------------------------------------------------------

Few people are done for independence, it is the privilege of the powerful ones.
---------------------------------------------------------------------------

No key was wounded during the drafting of this message.


More information about the Mono-list mailing list