Example:
<add key="Isemptydgaddroottext"Value=""/> <!--is it possible to modify the archive status profilefalse: Cannot modifytrueCan be modified--<add key="Isenableeditarchiveentry"Value="true"/> <!--whether to output the call log--<add key="Isenableoutputlog"Value="true"/> <!--Debug Status--<add key="Isdebug"Value="true"/> <!--debug Status user id--> <add key="Debuguserid"Value="DajkTest1"/> <!--debug Status user password--<add key="debuguserpwd"Value="dajktest1***"/>
Practice:
XmlDocument Xdoc =NewXmlDocument (); Creating an XML instanceif(File.exists ("Web. config")) {
If the file exists, operate Xdoc. Load ("Web. config"); XmlNodeList adds= Xdoc. SelectNodes ("//appsettings/add");
Create a method to read the node and locate the corresponding node (Add sub-node under appsettings)
if( This. rbentrystatey.checked) {
//Find the first property corresponding to the 11th node and modify the value adds[ One]. attributes[1]. Value ="true"; } Else if( This. rbentrystaten.checked) {adds[ One]. attributes[1]. Value ="false"; } if( This. rblogy.checked) {adds[ A]. attributes[1]. Value ="true"; } Else if( This. rblogn.checked) {adds[ A]. attributes[1]. Value ="false"; } if( This. rbdebugstatey.checked) {adds[ -]. attributes[1]. Value ="true"; } Else if( This. rbdebugstaten.checked) {adds[ -]. attributes[1]. Value ="false"; } adds[ -]. attributes[1]. Value =Debuguserid; adds[ the]. attributes[1]. Value =debuguserpwd; All the changes are complete, save the XML file Xdoc. Save ("Web. config"); }
Reading XML nodes using C #, modifying XML nodes