XMLDocument;
void CreateDocument() { _di_IXMLDocument document = interface_cast<Xmlintf::IXMLDocument> (new TXMLDocument(NULL)); document->Active = true; // Define document content. document->DocumentElement = document->CreateNode("ThisIsTheDocumentElement", ntElement, ""); document->DocumentElement->Attributes["attrName"] = "attrValue"; _di_IXMLNode nodeElement = document->DocumentElement->AddChild ("ThisElementHasText", -1); nodeElement->Text = "Inner text."; _di_IXMLNode nodeCData = document->CreateNode("any characters here", ntCData, ""); document->DocumentElement->ChildNodes->Add(nodeCData); _di_IXMLNode nodeText = document->CreateNode("This is a text node.", ntText, ""); document->DocumentElement->ChildNodes->Add(nodeText); document->SaveToFile(destPath); }
时间: 2024-11-10 11:34:38