Using system. xml;
// Initialize an XML instance
Xmldocument xml = new xmldocument ();
// Import the specified XML file
XML. Load (PATH );
XML. Load (httpcontext. Current. server. mappath ("../7in10. xml "));
// Specify a node
Xmlnode root = xml. selectsinglenode ("/root ");
// Obtain all direct subnodes under a node
Xmlnodelist childlist = root. childnodes;
// Determine whether a subnode exists under the node
Root. haschildnodes;
// Obtain the set of nodes with the same name as the peer node
Xmlnodelist nodelist = xml. selectnodes ("/root/News ");
// Generate a new node
Xmlelement node = xml. createelement ("news ");
// Add a node to a specified node as its subnode
Root. appendchild (node );
// Add the node to a subnode under the specified Node
Root. insertbefore (node, root. childenodes );
// Create a property for the specified node and assign a value to it
Node. setattribute ("ID", "11111 ");
// Add a subnode to a specified Node
Root. appendchild (node );
// Obtain the specified attribute value of a specified Node
String id = node. attributes ["ID"]. value;
// Obtain the text in the specified Node
String content = node. innertext;
// Save the XML file
XML. Save (PATH );
XML. Save (httpcontext. Current. server. mappath ("../7in10. xml "));