// <! [CDATA [
SYS. webforms. pagerequestmanager. _ initialize ('ajaxholder $ scriptmanager1 ', document. getelementbyid ('form1 '));
SYS. webforms. pagerequestmanager. getinstance (). _ updatecontrols (['tajaxholder $ updatepanel1'], [], [], 90 );
//]>
Simple VC Method for operating XML files
First, create an XML file. My machine software configuration is as follows: Windows XP Professional sp2ie 6.0 (irrelevant) vs 2003 examples # import <msxml3.dll> // I have no idea why msxl4 cannot be used // In my PC, may be something on personal // Discrimination Using namespace msxml2; // The same to above // create a file int createxmlfile (char * xml_file_name ){ // Create an XML file named xml_file_name comtemporily // If the return Val is "0", it means that creation // If failed: coinitialize (null); // This item must be encoded DED // It is fatal, else it will failed // Then at last ": couninitialize ();" // Matched msxml2: ixmldomdocumentptr pdoc; hresult hR = pdoc. createinstance (_ uuidof (domdocument30 ));// // <Msxml3.dll> version is 3.0 if (! (Succeeded (HR) // faild { Return 0; } Msxml2: ixmldomelementptr pPolicy = pdoc-> createelement ("local"); pdoc-> appendchild (pPolicy); {// The brackets including 1, 2, 3 can show // Tree structure of the XML file // Nodes // 1 Msxml2: ixmldomelementptr ppolicytype; Ppolicytype = pdoc-> createelement ("North "); Ppolicytype-> puttext ("piking "); PPolicy-> appendchild (ppolicytype ); Ppolicytype = pdoc-> createelement ("South "); PPolicy-> appendchild (ppolicytype ); {// 2.1 Msxml2: ixmldomelementptr pcontroltype; Pcontroltype = pdoc-> createelement ("Shanghai "); Pcontroltype-> puttext ("Xujiahui "); Ppolicytype-> appendchild (pcontroltype ); Pcontroltype. Release (); } // End 2.1 Ppolicytype = pdoc-> createelement ("East "); PPolicy-> appendchild (ppolicytype ); {// 2.2 Msxml2: ixmldomelementptr pprocesstype; Pprocesstype = pdoc-> createelement ("Heilongjiang "); Pprocesstype-> puttext ("Harbin, QiQihar "); Ppolicytype-> appendchild (pprocesstype ); Pprocesstype = pdoc-> createelement ("Liaoning "); Pprocesstype-> puttext ("Shenyang, Dalian "); Ppolicytype-> appendchild (pprocesstype ); Pprocesstype. Release (); } // End 2.2 _ Variant_t varxml (xml_file_name ); Pdoc-> Save (varxml); // save the file PPolicy. Release (); Ppolicytype. Release (); } // End 1 pdoc. Release ();: couninitialize (); // Necessary it same as new and delete Return 1 .. <Location> <North> pingking </North> <South> <Shanghai> Xujiahui </Shanghai> </South> <East> <Heilongjiang> Harbin, QiQihar </Heilongjiang> <Liaoning> Shenyang, Dalian </Liaoning> </East> when a shard looks for a value to access the endpoint, if you want to read the value of <North>, write "North" directly, and pingking is returned, to access <Shanghai>, enter "South \ Shanghai". This is similar to the registry key value: char * getvaluefromxml (char * nodename) {// get the value of certain node named nodename // from the XML file // the return value 0 represent failure Char * nodevalue = NULL; : Coinitialize (null ); Msxml2: ixmldomdocumentptr pdoc; Hresult hR = pdoc. createinstance (_ uuidof (domdocument30 )); If (! (Succeeded (HR ))) { Return nodevalue; } HR = pdoc-> load ("book. xml "); If (! Succeeded (HR )) { Msxml2: ixmldomelementptr ppolicynode = pdoc-> getdocumentelement (); Msxml2: ixmldomelementptr pselectnode = ppolicynode-> selectsinglenode (nodename ); Nodevalue = _ com_util: convertbstrtostring (pselectnode-> text ); Ppolicynode. Release (); Pselectnode. Release (); } Pdoc. Release (); : Couninitialize (); Return nodevalue; } Finally, the access method for modifying the value of a node in the XML file is the same as that for int modify (const char * nodename, char * nodevalue). // The former indicates the end name, the latter is the string value of the node. {// Modify the value of node named as nodename // The new value is nodevalue // If the XML file is not existed then return // 0 : Coinitialize (null ); Msxml2: ixmldomdocumentptr pdoc; Hresult hR = pdoc. createinstance (_ uuidof (domdocument30 )); Int rtval = 0; If (! (Succeeded (HR ))) { Rtval = 0; Return rtval; } HR = pdoc-> load ("book. xml ");// File Name. If (! Succeeded (HR )) { Msxml2: ixmldomelementptr ppolicynode = pdoc-> getdocumentelement (); Msxml2: ixmldomelementptr 2. pselectnode = ppolicynode-> selectsinglenode (nodename ); Pselectnode-> puttext (nodevalue ); Pdoc-> Save ("book. xml "); Ppolicynode. Release (); Pselectnode. Release (); Rtval = 1; } Pdoc. Release (); : Couninitialize (); Return rtval; } Deleting a node
What is this?RemoveThe member function is done, similar to the search, first find the node to be deleted .. Of course, it will be saved after deletion. This is different and should be known ..