Today, C # is used to read the configuration file and delete the specified node. This is simple, but it will make a mistake if you don't pay attention to it. Come and share your experience.
Public void remove (videosource)
{
String innertext = videosource. typeid + videosource. Name + videosource. thumbpath + videosource. videopath;
Xmldocument xml = new xmldocument ();
XML. Load (system. Windows. Forms. application. startuppath + "/XML/videosourcexml. xml ");
// Obtain all the subnodes under the first videosources
Xmlnodelist = xml. selectsinglenode ("videosources"). childnodes;
Foreach (xmlnode item in xmlnodelist)
{
If (item. innertext = innertext)
{
// PS: If you use XML. removechild (item), The removed node is definitely not a child node of XML.
XML. selectsinglenode ("videosources"). removechild (item );
// Item. removeall (); All subnodes under item can be deleted.
Break;
}
}
XML. Save (system. Windows. Forms. application. startuppath + "/XML/videosourcexml. xml ");
}