Using system. xml;
Initialize an XML instance
Xmldocument xml = new xmldocument ();
Import a specified XML file
XML. Load (PATH );
XML. Load (httpcontext. Current. server. mappath ("../AA. xml "));
Specify a node
Xmlnode root = xml. selectsinglenode ("/root ");
Obtain all direct subnodes under a node
Xmlnodelist childlist = root. childnodes;
Determines whether a subnode exists under the node.
Root. haschildnodes;
Obtains a set of same-level nodes with the same name.
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 a node to a subnode under a specified Node
Root. insertbefore (node, root. childenodes [I]);
Creates a new attribute for a specified node and assigns a value to it.
Node. setattribute ("ID", "11111 ");
Add a subnode to a specified Node
Root. appendchild (node );
Obtains the attribute value of a specified node.
String id = node. attributes ["ID"]. value;
Obtain text from a specified Node
String content = node. innertext;
Save the XML file
XML. Save (PATH );
XML. Save (httpcontext. Current. server. mappath ("../AA. xml "));