1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
XmlDocument^doc = gcnew XmlDocument();
doc->Load("c:\\test2.xml");
XmlNode^ elem1 = doc->CreateNode(XmlNodeType::Element, "user", nullptr);
XmlNode^ elem2 = doc->CreateNode(XmlNodeType::Element, "file", nullptr);
XmlAttribute^ attribLogin = doc->CreateAttribute("login");
attribLogin->Value = "Nico";
elem1->Attributes->Append(attribLogin);
XmlAttribute^ attribPwd = doc->CreateAttribute("password");
attribPwd->Value = "pyright";
elem1->Attributes->Append(attribPwd);
elem1->InnerText = "";
XmlAttribute^ attribid = doc->CreateAttribute("id");
attribid->Value = "1";
elem2->Attributes->Append(attribid);
elem2->InnerText = "";
doc->ChildNodes[0]->ChildNodes[0]->ChildNodes[0]->AppendChild(elem1);
doc->ChildNodes[0]->ChildNodes[0]->ChildNodes[0]->ChildNodes[0]->AppendChild(elem2);
doc->Save("c:\\test2.xml"); |