>Alan try looking through this article at :-
>http://aspnet.4guysfromrolla.com/articles/112603-1.aspx
>It should guide you..
Thanks Patrick, that's quite clever. He just pulls the XML into a
dataset and uses the native method for writing. I'll have a go at that.
I don't see there's any advantage to using this method for reading the
file though, my code is a lot simpler.
I'll have a play and see if I can get it to work. Thanks again.
>Patrick
>
>"Alan Silver" <alan-> wrote in message
>news:ZvLwY2I2iO+...
>> Hello,
>>
>> I have a site that stores some info in an XML file. The file is pretty
>> simple, of the form...
>>
>> <Site>
>> <SiteName>Fred's Ferrets</SiteName>
>> <SomeVar>Whatever</SomeVar>
>> ... etc ...
>> </Site>
>>
>> So far I have just used a simple routine to read values from the file...
>>
>> public string SiteVars(string varName) {
>> DataSet dstSiteVars = new DataSet();
>> dstSiteVars.ReadXml(Server.MapPath("/") + @"\Site.xml");
>> XmlDataDocument xddSiteVars = new XmlDataDocument(dstSiteVars);
>> XmlNodeList xnlSiteVars = xddSiteVars.GetElementsByTagName(varName);
>> if (xnlSiteVars.Count == 1) {
>> return xnlSiteVars.Item(0).InnerText;
>> } else {
>> return "";
>> }
>> }
>>
>> This is fine, but now I want to be able to update/add values. I have
>> looked around a bit, but all the code is so complex that I can't help
>> but feel that it's OTT for what I need.
>>
>> Basically I would like to write a companion method for the above...
>>
>> public void UpdateSiteVar(string varName, string newValue) {
>> ...
>> }
>>
>> That when called would either update the existing value if it exists, or
>> add the new node/value to the file if it doesn't already exist.
>>
>> Can anyone help me here please? I'm sure it's really simple, but I'm
>> getting swamped with large examples.
>>
>> TIA
>>
>> --
>> Alan Silver
>> (anything added below this line is nothing to do with me)
>
>
--
Alan Silver
(anything added below this line is nothing to do with me)