c# - How to Update a XML Node? -


It's easy to read an XML file and get the exact node text, but how can I renew the node?

To read:

  Public Static String Received Settings (Settings type type, section type section) {XmlTextReader Reader = New XmlTextReader (HttpContext.Current.Request.MapPath ( APPSETTINGSPATH)); XmlDocument Document = New XmlDocument (); Document.Load (reader); XMLNode node = document. SelectionSellingLenode (String.format ("/ Myrnonym / MySbnod / {0} / {1}", Enom. Purse (typef (settings type), type toaster ()), anime purse (typef (section type), section.tostring ()))); Return node Intertext; }  

to write ...?

  Public static zero setsetting (type of settings type, section type type, string value) {try {XmlTextReader reader = new XmlTextReader (HttpContext.Current.Request.MapPath (APPSETTINGSPATH)); XmlDocument Document = New XmlDocument (); Document.Load (reader); XMLNode node = document. SelectionSellingLenode (String.format ("/ Myrnonym / MySbnod / {0} / {1}", Enom. Purse (typef (settings type), type toaster ()), anime purse (typef (section type), section.tostring ()))); Node.InnerText = Values; Node.Update (); } Hold (ex before) {new exception throw ("error:", prior); }}  

Note line, node. Updates (); Does not exist, but this is what I want :)

I looked at the XML text writer, but it will write the whole XML in a new file, and I need to update a value in the original node. You can save as a new file and then change the new file to the original name ... but should it be easy to correct?

Any of you have a sample code about doing this

The method is not required - Updating the intent property however, it only applies updates to memory, although you want to do rewrite the whole file - you just do not update a small part of it (At least, without lot none of the work and none outside) - box support).


Comments