TXMLDocumentRefresh (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example uses the Refresh function. An XML file is manipulated with 2 variables of type IXMLDocument: one writer and one reader.

Code

void Test_Refresh() {
	_di_IXMLDocument documentWr;
	_di_IXMLDocument documentRd;

	// Create an XML file.
	documentWr = interface_cast<Xmlintf::IXMLDocument>(new TXMLDocument(NULL));
	documentWr->Active = true;
	documentWr->DocumentElement = documentWr->CreateNode("TestElement",
		ntElement);
	documentWr->SaveToFile(destPath);

	// Load the XML file into memory. Display the XML text.
	documentRd = interface_cast<Xmlintf::IXMLDocument>(new TXMLDocument(NULL));
	documentRd->LoadFromFile(destPath);
	printf("%ls\n", documentRd->XML->Text);

	// Modify the XML file.
	documentWr->DocumentElement->Text = "Update.";
	documentWr->SaveToFile(destPath);

	// Refresh the image of the XML file in memory.
	// The XML text should contain the word "Update".
	documentRd->Refresh();
	printf("Refreshing...\n");
	printf("%ls\n", documentRd->XML->Text);
}

Uses