// Header file
# Include <XMLDoc. hpp>
# Include <xmldom. hpp>
# Include <XMLIntf. hpp>
// Operation
// Define variables
AnsiString GameTDJpath; // It can only be of the AnsiString type
AnsiString gamepath = "gamepath"; // only the AnsiString type is allowed
_ Di_IXMLDocument XmlNetbargpp = NewXMLDocument (); // create a new object
XmlNetbargpp-> Active = true; // activate
// Read
XmlNetbargpp-> LoadFromFile (ExtractFilePath (Application-> ExeName) + "netbar. xml"); // load xml (the dynamic path is obtained by combining the exe path and XML name)
XmlNetbargpp-> Active = false; // manually disable and enable it for multiple times
XmlNetbargpp-> Active = true; // manually disable and enable it for multiple times
GameTDJpathtext = XmlNetbargpp-> DocumentElement-> ChildNodes-> FindNode (gamepath)-> GetAttribute ("path"); // you can find the value of the path attribute of the node gametdj.
// Insert
_ Di_IXMLNode root = XmlNetbargpp-> DocumentElement; // obtain the ROOT node root.
Root = root-> AddChild ("game"); // Add a node
Root-> Attributes ["path"] = ""; // Add the attribute path value as null.
XmlNetbargpp-> SaveToFile ("netbar. xml"); // update XML only after saving
// Update
_ Di_IXMLNode nodeupdate = XmlNetbargpp-> DocumentElement-> ChildNodes-> FindNode (gamepath); // search for the gamepath Node
Nodeupdate-> AttributeNodes-> operator [] (0)-> NodeValue = (WideString) ("path value "); // set the path value of the first attribute under the node found by node.
XmlNetbargpp-> SaveToFile ("netbar. xml"); // update xml only after saving
// Delete
_ Di_IXMLNode node2 = XmlNetbargpp-> DocumentElement; // you can search for it and then delete it.
Node2-> ChildNodes-> Delete (WideString ("gamepath"); // Delete a node
GamepathXmlNetbargpp-> SaveToFile ("netbar. xml"); // The XML is updated only after being saved.
<Pre>
From an empty column