The XML file format is as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<userdata createuser= "false" >
<dataconnection>
<server>localhost</server>
<uid>sa</uid>
<pwd></pwd>
</dataconnection>
<net>
<name>jiayuan</name>
</net>
</userdata>
Read a property in a node
XmlDocument doc=new XmlDocument ();
Doc. Load ("config +");
XmlNode Xnuser=doc. selectSingleNode ("UserData");
String Flag=xnuser. attributes["CreateUser"]. InnerText;
Reading values from a node
XmlDocument doc=new XmlDocument ();
Doc. Load ("config +");
XmlNode xnserver = doc. selectSingleNode ("Userdata/dataconnection/server");
Changing the properties of a node
XmlDocument doc=new XmlDocument ();
Doc. Load ("config +");
XmlNode Xnuser=doc. selectSingleNode ("UserData");
Xnuser. attributes["CreateUser"]. Innertext= "false";
Doc. Save ("config +");
Append node
XmlDocument doc = new XmlDocument ();
XmlTextReader reader = new XmlTextReader ("config +");
Doc. Load ("config +");
XmlElement root = Doc. DocumentElement; Get root node
XmlElement tagmessage = doc. createelement ("net");
XmlElement Tagtext = doc. createelement ("name");
Tagtext.innertext = NetName;
Tagmessage.appendchild (Tagtext); Append to the last side of the XML text
Root. AppendChild (Tagmessage);
Reader. Close (); Close XmlTextReader
Doc. Save ("config +"); Save the XML file
XML file format such as the following